mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-02-16 20:13:49 +00:00
27 lines
603 B
TypeScript
27 lines
603 B
TypeScript
import { z } from 'zod';
|
|
import BeerCommentValidationSchema from '../validation/CreateBeerCommentValidationSchema';
|
|
|
|
const sendCreateBeerCommentRequest = async ({
|
|
beerPostId,
|
|
content,
|
|
rating,
|
|
}: z.infer<typeof BeerCommentValidationSchema>) => {
|
|
const response = await fetch(`/api/beers/${beerPostId}/comments`, {
|
|
method: 'POST',
|
|
headers: {
|
|
'Content-Type': 'application/json',
|
|
},
|
|
body: JSON.stringify({
|
|
beerPostId,
|
|
content,
|
|
rating,
|
|
}),
|
|
});
|
|
|
|
const data = await response.json();
|
|
|
|
console.log(data);
|
|
};
|
|
|
|
export default sendCreateBeerCommentRequest;
|