0

I have two different types of possible API class I can make. The first one is:

http://api_url.com/api/v1/schools/countries/BR

and the second one is:

http://api_url.com/api/v1/schools/countries/BR?admin1=MA

My route in backend/routes/schools.js is:

router.get('/countries/:country', forward_get);

  const forward_get = (req, res, next) => {
  console.log(req);
  const url = `${url}${req.originalUrl}`
  getResponse(url, acToken, res);
}

How do I make it so that I am able to also make the second api call and get the appropriate parameters "admin1: MA". Ive gone through the whole req object and I don't seem to find them anywhere. So far I've been able to make the first api call without a problem.

39fredy
  • 1,781
  • 1
  • 18
  • 38

1 Answers1

1

This is the only route you need:

You access admin1 using req.query.admin1

and

You access country using req.params.country

Amr Labib
  • 3,847
  • 3
  • 18
  • 31