What are you trying to accomplish
I want to post data to a custom model. I have tried write api but its not working and giving 404 error. Please let me know how can i achieve it?
Code stack you are integrating Builder with
NextJS, swell js, typescript
Reproducible code example
const dataObject = {
name: 'Test',
data: {
userName: 'Anu',
review: 'Testing',
productSlug: 'demo-product',
date: new Date(),
rating: 4
}
}
const postData = async (url: string, data: any) => {
const response = await fetch(url, {
body: JSON.stringify(data),
headers: {
Authorization: "Bearer " + process.env.privateKey,
"Content-Type": "application/json"
},
method: "POST"
})
return response.json();
}
postData('https://builder.io/api/v1/write/reviews', dataObject)
.then((data) => {
console.log('data: ', data);
})