mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
Feat: Add create brewery comments and brewery cluster map
This commit is contained in:
@@ -8,18 +8,11 @@ const sendBreweryPostLikeRequest = async (breweryPostId: string) => {
|
||||
const json = await response.json();
|
||||
|
||||
const parsed = APIResponseValidationSchema.safeParse(json);
|
||||
|
||||
if (!parsed.success) {
|
||||
throw new Error('Invalid API response.');
|
||||
}
|
||||
|
||||
if (!parsed.success) {
|
||||
throw new Error('Invalid API response.');
|
||||
}
|
||||
|
||||
const { success, message } = parsed.data;
|
||||
|
||||
return { success, message };
|
||||
return parsed.data;
|
||||
};
|
||||
|
||||
export default sendBreweryPostLikeRequest;
|
||||
|
||||
@@ -18,13 +18,12 @@ const sendCreateBeerCommentRequest = async ({
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ beerPostId, content, rating }),
|
||||
});
|
||||
if (!response.ok) {
|
||||
throw new Error(response.statusText);
|
||||
}
|
||||
|
||||
const data = await response.json();
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(data.message);
|
||||
}
|
||||
|
||||
const parsedResponse = APIResponseValidationSchema.safeParse(data);
|
||||
|
||||
if (!parsedResponse.success) {
|
||||
|
||||
Reference in New Issue
Block a user