如何解决django rest auth用户未使用put或patch方法进行更新
我正在使用django-rest-auth作为用于处理帐户的API,并且前端有React。我已经使用令牌和填充从“ rest-auth / user”成功检索了数据。但是,当我使用“ PUT”方法或“ PATCH”方法更新first_name,last_name和username的数据时,数据未更新,但未返回错误。在控制台中,promiseStatus已“实现”,并且promiseValue返回了这些值的对象,而未进行更新。
const updateData = (e) => {
e.preventDefault();
const csrftoken = getCookie("csrf");
const cookies = new Cookies();
const url = "http://localhost:8000/rest-auth/user/";
setIsLoading(true);
fetch(url,{
method: "PATCH",headers: {
"Content-Type": "application/x-www-form-urlencoded",Authorization: "Token " + cookies.get("token"),"X-CSRFToken": csrftoken,},body: JSON.stringify({
username: username,first_name: firstName,last_name: lastName,}),}).then((response) => console.log("THE RESPONSE: ",response.json()));
setIsLoading(false);
};
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。