I have django restframework
and control from javascript axios
What I am doing is like this,
axios.get(`http://localhost:8010/api/myusers/?my_id=${my_id}`).then((res)=>{
var id = res['data']['results'][0]['id'];
axios.patch(`http://localhost:8010/api/myusers/${id}/`, {
phone: 'nice phone',
}).then((res)=>{
console.log("patch finish");
})
})
Fetch the id by my_id and patch the data.
However I think it is a bit clumsy, it uses twice request.
At first get the id
by my_id
and change data by id
So, I would like to do this by one request.
How can I make it ?
I tried like this but 405 Method not allowd
error
axios.patch(`http://localhost:8010/api/myusers/?my_id=${my_id}`, {
phone: 'nice phone2',
}).then((res)=>{
console.log("patch finish");
})