[英]Problem put axios update user Strapi and NuxtJS
I have a problem with the right in strapi .我在Strapi的右边有问题。
I create user with the role Authenticated and try modified the data with axios.我创建了具有 Authenticated 角色的用户,并尝试使用 axios 修改数据。
But it is impossible has modified because return forbidden.但不可能因为退货被禁止而修改了。 I look if the user has right, Update is check in role authenticated.我看用户是否有权,更新是签入身份验证的角色。
If i check update in role public, my modification with axios is ok.如果我在角色 public 中检查更新,我对 axios 的修改就可以了。 Why ?为什么 ? I don't undestand the problem.我不明白这个问题。
My code for send我的发送代码
.put(
`https://localhost:4000/users/${this.data.id}`,
{
headers: {
Authorization: `Bearer ${token}`
},
Nom: 'JEAN'
}
)
.then((res) => {
// Handle success.
console.log(res)
})
.catch((error) => {
// Handle error.
console.error('An error occurred:', error)
})```
Thank you
I'm not sure the axios request has the right format.我不确定 axios 请求的格式是否正确。
According to this documentation - https://github.com/axios/axios#axiosconfig根据此文档 - https://github.com/axios/axios#axiosconfig
This probably should look like this:这可能应该是这样的:
axios({
method: 'put',
url: `https://localhost:4000/users/${this.data.id}`,
data: {
username: 'JEAN'
},
headers: {
Authorization: `Bearer ${token}`
}
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.