Home > Back-end >  TypeError on fetch request on "e-raktakosha" web site api
TypeError on fetch request on "e-raktakosha" web site api

Time:05-10

I am new to javascript. I was trying to make an api call. My code

const options = {
  method: 'GET',
  headers: {
    Authorization: 'Basic dW5kZWZpbmVkOnVuZGVmaW5lZA==',
    'content-type': 'application/json',
  }
};
fetch(
  'https://www.eraktkosh.in/BLDAHIMS/bloodbank/nearbyBB.cnt?hmode=GETNEARBYSTOCKDETAILS&stateCode=21&districtCode=378&bloodGroup=all&bloodComponent=11&lang=0',
  options
)
  .then((response) => response.json())
  .then((response) => console.log(response))
  .catch((err) => console.error(err));

but I encountered with an error saying

Error: Failed to fetch
  1. This api call works perfectly with GET warning of body/payload usage

    It is better to just avoid sending payloads in GET requests.

  • Related