1

I'm trying to send get method request and want to pass value in URL.

Like my api look like

app.get('/api/getlocation/:customerName', customer.getlocation);

For call this I wrote in postman

localhost:8080/api/getlocation/:customerName=kumbhani

For test

var customerName = req.params.customerName;
console.log('name', customerName); // =kumbhani

It returns name with = sign - I want only kumbhani

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
kumbhani bhavesh
  • 2,189
  • 1
  • 15
  • 26

1 Answers1

2

The colon character in the path in Express has a special meaning: whatever you put in the URL after getLocation/ will be put in req.params.customerName.

This means in Postman, you should actually call this URL:

localhost:8080/api/getlocation/kumbhani

See related question.

Community
  • 1
  • 1
Patrick Hund
  • 19,163
  • 11
  • 66
  • 95