0

I wan to retrieve my results that are stored inside the /geoCodes/geocode. I manage to insert values into it but I am unable to get the results to display in my html.

Strongloop explorer

Console to show results

        // maplink sample: http://maps.google.com/?q=37.2110625,-121.8054238
        var maplink = "http://maps.google.com/?q=" + lat + "," + lng;
        console.log('maplink is ' + maplink);
        // make a callback function cb
        cb(null,maplink);
sxxxxxxx
  • 565
  • 2
  • 6
  • 17
  • What exactly is the expected behavior, and how does actual behavior differs? – MarcoS Apr 04 '16 at 08:49
  • It will get the input and return a maplink which im already able to get but the results is displayed in the console which is not what I want. I want to place the return value(maplink) into my html. @MarcoS – sxxxxxxx Apr 04 '16 at 09:01
  • Will this code run in browser or server-side? You should supply some more 'contour' info... :-) – MarcoS Apr 04 '16 at 09:15
  • This code will run in the server-side. My inputs will be placed in the browser. @MarcoS – sxxxxxxx Apr 04 '16 at 09:21

1 Answers1

0

For a "browser" app to get values form a server, you have to setup a client-server interface. For example implement a RESTful API on your server (see express site, and for example this nice tutorial).
Your server side API will expose some methods (for example getGeoLocation), and then, in your client side app (in the browser), it'll be easy to get the values from your service (see for example this SO question/answers).

Community
  • 1
  • 1
MarcoS
  • 17,323
  • 24
  • 96
  • 174
  • I added my value into /geoCodes/geocode and there is only the post method. There is no get method for it. The photo of the explorer is in at the above. – sxxxxxxx Apr 04 '16 at 10:04
  • O.k., so you did setup an API with one POST method, accepting an address and returning a maplink (sorry, I'm quite sleepy, this morning, yet... :-). Perfect. You said you did test in in console and it works. Did you test it with curl, or in the browser? – MarcoS Apr 04 '16 at 10:13
  • Yup, i tried to retrieve the maplink to show in the browser but it doesn't work. How do I display the maplink? – sxxxxxxx Apr 04 '16 at 10:15
  • Please show the url you did put in the browser addres and the results in console. And, please, accept this answer... :-) – MarcoS Apr 04 '16 at 10:17
  • This is the url that i placd in the console: http://localhost:3000/#/find-location. The console displays the exact same thing as the one shown in the picture after I place the inputs. – sxxxxxxx Apr 04 '16 at 10:23
  • O.k. So your API do work remotely too. I would conclude the issue is in client code. Can you show the relevant portion? – MarcoS Apr 04 '16 at 10:34