https://github.com/salmandabbakuti/apiclient
HTTP API Client SDK for easier integration of API to plain html frontends using axios
https://github.com/salmandabbakuti/apiclient
api-server axios javasacript nodejs nodejs-server rest-api restful-api
Last synced: 3 months ago
JSON representation
HTTP API Client SDK for easier integration of API to plain html frontends using axios
- Host: GitHub
- URL: https://github.com/salmandabbakuti/apiclient
- Owner: Salmandabbakuti
- License: mit
- Created: 2020-08-09T06:15:53.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-04-21T08:22:20.000Z (about 2 years ago)
- Last Synced: 2025-02-16T05:02:52.215Z (3 months ago)
- Topics: api-server, axios, javasacript, nodejs, nodejs-server, rest-api, restful-api
- Language: JavaScript
- Homepage:
- Size: 27.3 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# apiClient
HTTP API Client SDK bundle for easier API integration to plain html frontends#### Usage:
- in your ```index.html```
```
//axios cdn
//apiClient sdk bundle```
##### In Nodejs run time:- Same module can be used in nodejs run time too.
###### Installation:
```
npm install -g apiclient-dev
``````
const { get, post } = require('apiclient-dev'); # v1.0.4 preferredasync function myFunction(){
const {err, response } = await get("http://localhost:8000/search", {username:"salman"})
// your code to handle response or error here
}
```
##### Get request:```
async function users(){
let url = "http://localhost:8000/users";
let dataObj = {username:"salman"}
const {err, response} = await get(url, dataObj);
}
```
##### Post request:```
async function login(){
let url = "http://localhost:8000/login";
let dataObj = {username:"salman", password:"12345"}
const {err, response} = await post(url, dataObj);
}
```##### Handling errors:
```
const {err, response} = await get("http:localhost:8000/search", {queryId:"cars"})//const {err, response} = await post(url, dataObj);
if(err) {
console.log(`it returned error: ${err}`)
else{
console.log(`it returned response: ${response}`)
```##### Author
##### :wave: [©Salman Dabbakuti](https://salmandabbakuti.github.io)