简体   繁体   中英

How do I pass to API body in GET method?

I have to pass the parameters to the body and not the query. I tried it like this.

const fetch=async()=>{
  let res =  await
    apiCall("URL" + {
      "companyArr":["SBI Life Insurance Company Ltd.","NTPC Ltd"],
      "secodeArr":["NSE","NSE"],
      "startDate":"Jul 1, 2022",
      "endDate":"Jul 13, 2022"
  },
  "GET",null)

console.log(res);
if (res.status === 200) {
    console.log(res.data.data);
}
  }

But I am getting 'Request failed with status code 404' error message. What is the correct way to go about this?

If you really need to send information in a GET call then you should probably look into using query parameters

Check this thread for more information: setting-query-string-using-fetch-get-request

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