简体   繁体   中英

How to solve: Axios request doesn't work while Postman can?

I'm sending a GET request using axios . What I'm trying to pass to this request is a raw data body (type: Object)

Here's the code:

export const getAssignQC = async (
  projectId,
  interviewId,
  userId,
  step,
  status,
  type
) => {

  try {

    return await axios({
      method: "get",
      url: "https://{myIp}/qualitycontrol/checkAssignQC",
      headers:{},
      data: {
        projectID: projectId,
        interviewID: interviewId,
        userID: userId,
        step: step,
        status: status,
        type: type,
      }
    });
  } catch (error) {
    console.log("Error in getting assign qc", error);
  }
};

Here's the result:

在此处输入图像描述

Network inspector

在此处输入图像描述 在此处输入图像描述

Meanwhile, the request works fine on Postman:

在此处输入图像描述

What I've tried :

  • Using FormData and assign to the data property: data: formData (the keys, values have been appended)

PLEASE HELP!

I think you are missing the double slash after 'https':

url: "https:{myIp}/qualitycontrol/checkAssignQC",

I have also made a working sample, if it helps: https://codesandbox.io/s/cold-thunder-iprks?file=/src/App.js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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