Browse Source

caching fields answers

master
analuizaff 3 years ago
parent
commit
967f5fbbe1
  1. 19
      src/app/api/client.js
  2. 1
      src/app/components/MapModal.js

19
src/app/api/client.js

@ -1,8 +1,21 @@
import { create } from 'apisauce'
import { create } from "apisauce";
import { useCallback } from "react";
import cache from "../utility/cache";
const apiClient = create({
baseURL: 'https://wpd.brazilsouth.cloudapp.azure.com/api'
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;

1
src/app/components/MapModal.js

@ -324,6 +324,7 @@ function MapModal({ showModal, setShowModal, markers }) {
id,
user
);
// console.log(result)
if (result.data && showModal && currentMarker == undefined) {
AssembleModalObject(
JSON.stringify(result.data.responseData),

Loading…
Cancel
Save