UNPKG

@vtmap/vtmap-sdk-js

Version:

JS SDK for accessing Viettelmaps APIs

35 lines (29 loc) 1.06 kB
'use strict'; var MapiRequest = require('./mapi-request'); var constants = require('../constants'); /** * A low-level Mapbox API client. Use it to create service clients * that share the same configuration. * * Services and `MapiRequest`s use the underlying `MapiClient` to * determine how to create, send, and abort requests in a way * that is appropriate to the configuration and environment * (Node or the browser). * * @class MapiClient * @property {string} accessToken - The Mapbox access token assigned * to this client. * @property {string} [origin] - The origin * to use for API requests. Defaults to https://api.mapbox.com. */ function MapiClient(options) { if (!options || !options.accessToken) { throw new Error('Cannot create a client without an access token'); } this.accessToken = options.accessToken; this.origin = options.origin || constants.API_ORIGIN; } MapiClient.prototype.createRequest = function createRequest(requestOptions) { return new MapiRequest(this, requestOptions); }; module.exports = MapiClient;