0

I'm working in a MEAN app, in which I want to pass an array value to url and fetch values from mongodb. Actually it's a lat and lng. My url should look like:

http://localhost:8080/search?type=latlng&value=[0.123, 0.456]

And have to fetch data related to that lat lng. How to do that?

0

1 Answer 1

0

You cannot pass literal array objects in the URL like you propose. There are workarounds however. You must either separate the data into {key}={value} pairs within the URL, or use a POST request.

GET: http://localhost:8080/search?type=latlng&lat=0.123&lng=0.456
     http://localhost:8080/search?type=latlng&coords[]=0.123&coords[]=0.456

POST: http://localhost:8080/search 
      data: { type: 'latlng', value: [0.123, 0.456] }
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.