rapidjs / rapidjs.io

The docs for rapid.js

Home Page:http://rapidjs.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Make a sample endpoint interface

drewjbartlett opened this issue · comments

Would love to show how you could wrap this:

https://developers.google.com/places/web-service/search

class GoogleMapsPlace extends Rapid {
    
    textSearch (query) {
        this.withParam({ query: query });

        return this;
    }

    json () {
        this.setURLParams('json');

        return this;
    }

    xml () {
        this.setURLParams('xml');

        return this;
    }
}

var GoogleMapsPlaces = new GoogleMapsPlace({
   baseURL: 'https://maps.googleapis.com/maps/api/place',
   globalParameters: {
      key: 'YOUR_API_KEY'
   }
});

GoogleMapsPlaces.textSearch('123+main+street').json().get();

// https://maps.googleapis.com/maps/api/place/textsearch/json?query=123+main+street&key=YOUR_API_KEY