Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

tayyabshahzad1's avatar

Javascript Execution

Hi, I have javaScript code for GoogleMap, what I am doing I am passing my lat and lng and in return, google Map provides me the list of locations, I simply convert that list to JSON.

Now I want that JSON response in API call in return response, But when I hit my end point in POSTMAN instead of response I am getting my whole code of JavaScript. I know the reason because javascript is a client-side language so that why I am getting the whole code, but I need a solution for that please guide me.

0 likes
6 replies
Snapey's avatar

you are calling the google api from the server?

tayyabshahzad1's avatar

@Snapey I am trying to explain you. I have code in javascript, that code takes the lat & lng address, the code print min list of places which are in my given lat & lang. for now, I simply take that JSON and print it into my div which is on my HTML page.

Now comes to the required part, my first challenge is fixed because I get a JSON list. Now I want to make an API. App Dev put lat and lang address in API and I will simply return a JSON list of places that will be in given lat & lng.

Now I am testing code into my postman, when I hit my endpoint instead of that response I am getting the whole javascript code that is on my page. I hope you understand what I want to achieve @sinnbeck shared one laravel package but I can't find the solution for my challenge.

Sinnbeck's avatar

@tayyabshahzad1 You cannot call a web page with Javascript as an api request.

There are two solutions which I gave you. Which one did you try?

Please or to participate in this conversation.