Reputation: 63
i am trying to send a patch request to update or maybe change the image in directus CMS.. (changing it require only id of the item and the file which is already solved.. in this link
Make Multiple Post Requests In Axios then get all the response to make another request)
below is the simplified code of it because the thing i am trying to achieve is making an item that have name, email, date, etc. then sending file or an image to the files ..
then i need to patch the item that i just made which is where i am not able to do yet..
for information only.. i am using gatsbyjs..
i have already tried it in postman and it works.. maybe there is something wrong with my code. thanks..
axios.patch( `${process.env.GATSBY_DIRECTUS_API_URL}/gemaclc/items/pendaftar/49?access_token=${process.env.GATSBY_DIRECTUS_TOKEN}`, {
data: JSON.stringify( {
kartu_keluarga: 1,
}),
})
Upvotes: 1
Views: 247
Reputation: 63
i deleted JSON.stringify and it works
axios( `${process.env.GATSBY_DIRECTUS_API_URL}/gemaclc/items/pendaftar/50?access_token=${process.env.GATSBY_DIRECTUS_TOKEN}`,
{
method:"patch",
data :{
kartu_keluarga: 1,
nama: "zidsadanaaa"
},
}
)
Upvotes: 1