My goal is to be able to insert data using JavaScript fetch method.
Inserting the post worked like a charm,
but I can only insert the post title and status.
How can I insert ACF data?
fetch('http://mywebsite.com.br/wp-json/wp/v2/athletes/',{
method: "POST",
headers:{
'Content-Type': 'application/json',
'accept': 'application/json',
'Authorization': `Bearer ${this.state.userToken}`
},
body:JSON.stringify({
title: 'my custom post title',
status: 'publish',
acf: {
my_field: 'my acf value here'
}
})
}).then( (response) => {
return response.json();
}).then( (post) => {
console.log(post);
});