forked from cemaden-educacao/WPD-MobileApp
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
551 B
21 lines
551 B
import { create } from "apisauce";
|
|
import { useCallback } from "react";
|
|
import cache from "../utility/cache";
|
|
|
|
const apiClient = create({
|
|
baseURL: "https://wpd.brazilsouth.cloudapp.azure.com/api",
|
|
});
|
|
|
|
const get = apiClient.get;
|
|
apiClient.get = async (url, params, axiosConfig) => {
|
|
const response = await get(url, params, axiosConfig);
|
|
|
|
if (response.ok) {
|
|
cache.store(url, response.data)
|
|
return response;
|
|
}
|
|
const data = JSON.parse( await cache.get(url));
|
|
return data ? {ok:true, data} : undefined;
|
|
};
|
|
|
|
export default apiClient;
|