I created a User schema with the Name string field. Using POST I can create a new record but not with graphql.
const handleCreateUser = useCallback(() => {
fetch('https://site-api.datocms.com/items', {
method: 'POST',
headers: {
Authorization: 'Bearer ...',
Accept: 'application/json',
'X-Api-Version': '3',
'Content-Type': 'application/vnd.api+json'
},
body: JSON.stringify({
data: {
type: 'item',
attributes: {
name: '...',
},
relationships: {
item_type: {
data: {
type: 'item_type',
id: '...'
}
}
}
}
}),
})
.then((res) => {
console.log(res);
return res.json();
})
.then((data) => {
console.log(data);
});
}, []);
Thank you guys!