问题描述
我正在使用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 (将#修改为@)