R
React Native
Section Guide
Universal Fetch implementation.
`useDsiApi.js`
javascript
import { Buffer } from 'buffer';
export const dsiRequest = async (method, table, data = {}) => {
const token = Buffer.from("PgcQqi8ZGmlnYwd50JKo74_secure_token_2024").toString('base64');
const ts = Buffer.from(Math.floor(Date.now() / 1000).toString()).toString('base64');
const body = new URLSearchParams({
token,
timestmp: ts,
method,
table,
...data
}).toString();
const response = await fetch("https://fake-api.devsecit.com/1.0.0/wb/", {
method: 'POST',
headers: {
'Authorization': 'Bearer YOUR_SECRET',
'Content-Type': 'application/x-www-form-urlencoded'
},
body
});
return await response.json();
};