react-api-codeby
This react-api-codeby library supports only ReactJS. Api.Codeby is a simple tool that lets you easily create APIs, generate custom data, and preform operations on it using RESTful interface.
Installation
You can use any NPM-compatible package manager, including NPM itself and Yarn.
yarn add react-api-codeby
Then:
# from root folder
mkdir -p "src/configs" && cd $_
vi apiCodeby.js
apiCodeby.js
import {ApiCodeby, MediaCodeby, AuthCodeby} from "react-api-codeby";
const Config = {
"baseURL": "http://be.mockapi.test/api/restful",
"token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJkYXRhc2V0X2lkIjoyMywidXNlcl9pZCI6MX0.xeya_ZUfNtoGHAkHVvpO9Qx9uI7jKN-0a6VOaBb4L1Q",
"default": {
"thumb": "http://localhost:3011/assets/default/thumb.png",
"image": "http://localhost:3011/assets/default/image.png",
},
"lang": {
"_username": "Email",
"_password": "Password",
},
"auth": {
"tokenKey": "ripcode-token",
"resource": "users"
}
}
ApiCodeby.config(Config)
MediaCodeby.config(Config)
AuthCodeby.config(Config)
export {
AuthCodeby as authCodeby,
ApiCodeby as apiCodeby,
MediaCodeby as mediaCodeby,
}
Usage/Examples
import {apiCodeby} from "configs/apiCodeby";
import {useEffect} from "react";
function App() {
useEffect(() => {
(async () => {
const res = await apiCodeby.get('/configs')
console.log('res', res)
})()
})
return (
<div className="App">
Open console.log in browser to see the result
</div>
);
}
export default App;