繁体   English   中英

Axios 请求中止

[英]Axios Request Aborted

我有一个 axios 发布请求,当我们点击按钮时它会被触发。 但是一旦单击按钮,它就会显示此错误并重新加载页面

在此处输入图像描述

触发请求的 function

const handleForm = async (e) => {
//Check username is unique
e.preventDefault();
const oldUserName = await doesUserNameExist(userName);
if (oldUserName) {
  activeUser.displayName = userName;
  const imgUrl = await uploadPhoto(activeUser?.displayName, profilePicture);
  const userFormData = {
    userName,
    bio,
    gender,
    age,
    uid: activeUser.uid,
    emailAddress: activeUser.email,
    accountCreatedOn: serverTimestamp(),
    lastSeen: serverTimestamp(),
    following: [''],
    followers: [''],
    role: 'user',
    status: '',
    photoURL: imgUrl ? imgUrl : activeUser?.photoURL,
  };

  //  await addUser(userFormData);
  const nodeData = {
    id: activeUser.uid,
    emailAddress: activeUser.email,
    userName,
  };
  await axios.post('path_to_api/api/user', nodeData, {
    headers: nodeData,
  }); 
}

请帮忙。 提前致谢!!

尝试这个:

 await axios.post('path_to_api/api/user', nodeData); 

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM