Node.js Express REST API - accessing JSON url params with GET request -


I have a final end point, which is / geo / search and long to be sent as part of it Requires Latitude / Coordinate Request (Geo Polygon).

  • Is there a way that I can use JSON in the GET request? I was thinking that URL encoding can be a solution: data on encodeurIComponent ({"coordinate": [[122.610168,37.598167], [- 122.288818,37.598167], [- 122.2,88,818, 37.845833], [- 122.610168,37.845833], [- 122.610168,37.598167]]});

  • How do I access these parameters in the path?

  • Reply to # 1 - Thanks @ MCCF

    Using JQuery.param:

    Customer:

      test = {"coordinate": [[- 122.610168,37.598167], [- 122.288818, 37.598167], [-122.288818,37.845833], [- 122.610168,37.845833], [- 122.610168,37.598167]]}; Console.log ($. Ultimate (test));  

    Output:

      Coordinates% 5B0% 5D% 5b% 5D = -122.6,10,168 & amp; Coordinate% 5B0% 5D% 5b% 5D = 37.5, 98167 & amp; Coordinate% 5B1% 5D% 5b% 5D = -122.2,88818 & amp; Coordinate% 5B1% 5D% 5b% 5D = 37.5, 98167 & amp; Coordinate% 5B2% 5D% 5b% 5D = -122.2,88818 & amp; Coordinate% 5B2% 5D% 5b% 5D = 37.845833 & amp; Coordinate% 5B3% 5D% 5b% 5D = -122.6,10,168 & amp; Coordinate% 5B3% 5D% 5b% 5D = 37.845833 & amp; Coordinate% 5B4% 5D% 5b% 5D = -122.6,10,168 & amp; Thanks for Broad:  

    Server - Express way:

        

    Router .Get ('/ search_polygon', function (request, race) {console.log ('server received:' + JSON.stringify (req.query.coordinates)); ...

    < P> Output:

      Server received: [["-122.6,10,168", "37.5, 98167"], ["- 122.2,88, 818 "," 37.5, 98167 "], [" - 122.2, 88,818 "," 37.8,45,833 "], [" -122.6,10,168 "," 37.8,45,833 "], [" - 122.6,10,168 "," 37.5, 98167 "]]  

    My issue is part of the path In the cross as The was trying to, and not as in as parameters that they should be.


Comments

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -