API_CALL Format changed #54

Closed
ebube.ojinta wants to merge 1 commits from myFit--BlogDetails into master
2 changed files with 2 additions and 21 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ const Main = ({ brdcum, bgimg }) => {
// Set a time out for the blog data to be deleted from local storage
setTimeout(() => {
localStorage.removeItem("myFit--blogData");
}, 3600);
}, 3600000);
} catch (error) {
console.log("Error from blog data ", error);
}
+1 -20
View File
@@ -19,33 +19,14 @@ const Main = ({ brdcum }) => {
}, [blogData]);
const getBlogData = async () => {
/*
The reason for this, is because of the breaking I had when building the blog
I decided to save to the local storage for an hour so that it won't need to be going to the server again but I can change this
*/
// Saving it locally to avoid interfering with server
if (localStorage.getItem("myFit--blogData") == null) {
try {
let res = await api_call.blogData();
// Set the blog data to local storage
localStorage.setItem("myFit--blogData", JSON.stringify(res.data));
setBlogData(res.data);
// Set a time out for the blog data to be deleted from local storage
setTimeout(() => {
localStorage.removeItem("myFit--blogData");
}, 3600);
} catch (error) {
console.log("Error from blog data ", error);
}
} else {
try {
let data = JSON.parse(localStorage.getItem("myFit--blogData"));
setBlogData(data);
} catch (error) {
console.error("Error parsing JSON data: ", error);
}
}
};
return (