Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Axios(config) is throwing Error. #81

Open
pranshukas opened this issue May 14, 2021 · 1 comment
Open

Axios(config) is throwing Error. #81

pranshukas opened this issue May 14, 2021 · 1 comment

Comments

@pranshukas
Copy link

the Axios Config is not working it's throwing Error!

function getSlotsForDate(DATE) {
    let config = {
        method: 'get',
        url: 'https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode=' + '201310' +'&date=' + DATE,
        headers: {
            'accept': 'application/json',
        }
    };

    axios(config)
        .then(function (slots) {
            let sessions = slots.data.sessions;
            let validSlots = sessions.filter(slot => slot.min_age_limit <= AGE && slot.available_capacity > 0)
            console.log({ date: DATE, validSlots: validSlots.length })
            if (validSlots.length > 0) {
                notifyMe(validSlots);
            }
        })
        .catch(function (error) {
            console.log(error);
        });
}

I tried running this function but it's throwing an error.

image

Can Anyone please suggest us why this is happening or how else can we implement the same thing. I also tried using the request package which is getting executed perfectly but I am not able to get sessions from it.
it's showing .filter is not function.


   var options = {
      'method': 'GET',
      'url': 'https://cdn-api.co-vin.in/api/v2/appointment/sessions/public/calendarByPin?pincode=' + '201301' + '&date=' + DATE,
       headers': {
         'Accept-Language': 'en_US'
       }
    };
      request(options, function (error, response) {
      if (error) {
          throw new Error(error);
      }
      let slots = JSON.parse(response.body);
      console.log(slots.centers.length);  
      let sessions = slots.data.sessions;
      let validSlots = sessions.filter(slot => slot.min_age_limit <= AGE && slot.available_capacity > 0)
      console.log({ date: DATE, validSlots: validSlots.length }) 
    });
@saymedgm
Copy link

Problem is in the api errors 403 means it is not able to authorize I tried displaying api through axios it is showing same error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants