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

Gabotronix's avatar

Using google places API in node.js server enviroment

Hi everybody, this is my first node.js application where I will be using javascript in the server, previously I used google places API javascripe in the client, like this:

async codeAddressFromList(address)
    {
        const self = this;
        this.address = address;
    
        return self.geocoderService.geocode( { 'address': address}, function(results, status)
        {
            if (status == 'OK')
            {
                self.map.setCenter(results[0].geometry.location);
                self.calculateNewSquareVertex(results[0].geometry.location);
                self.drawRects();
            } 
            else
            {
                alert('Geocode was not successful for the following reason: ' + status);
            }
        });
    },

I was wondering what's the best way to use google places API in node.js.

Since node is javascript in the server will I be able to use the javascript API in the server? I have seen some people using axios to make requests and using query strings, I have also found about this library:

https://github.com/googlemaps/google-maps-services-js

But I'm not sure about suing a lib, what is the more vanilla, battle tested way to do this?

Can you guys post some of your node.js google places API examples?

0 likes
1 reply
automica's avatar

@gabotronix I might hazard that your question is pretty niche for Laracasts. Maybe worth throwing it over to stackoverflow for double chance of replies if you haven't already.

Please or to participate in this conversation.