UNPKG

@questlabs/react-native-sdk

Version:
29 lines (23 loc) 654 B
import config from "../config"; import { props } from "./GeneralTypes"; class General { async makeRequest({ url, method, body, headers, query }: props) { try { if (query) { const queryString = new URLSearchParams(query).toString(); url = `${url}?${queryString}`; } const response = await fetch(config.BACKEND_URL + url, { method, headers, ...(body && { body: JSON.stringify(body) }), }); return response.json(); } catch (error) { console.log(error); throw error } } } const general = new General(); export default general;