Skip to content

Commit

Permalink
getBlogs function
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanBonsignori committed Mar 22, 2024
1 parent 043e14e commit 8937b8b
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/utils/blogApi.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,24 @@ const origin =
? process.env.REACT_APP_PROD_ORIGIN
: process.env.LOCAL_ORIGIN;

export async function getBlogs() {
try {
const route = `${baseRoute}/getBlogs`;
const res = await window.fetch(route, {
mode: 'cors',
method: 'GET',
origin,
});
if (res.status !== 200) {
return console.error('Error fetching blogs:', await res.json());
}
const data = await res.json();
return data;
} catch (err) {
return console.error(err);
}
}

export async function getBlog(blog) {
try {
const route = `${baseRoute}/getBlog/${blog}`;
Expand Down

0 comments on commit 8937b8b

Please sign in to comment.