@googlemaps/google-maps-services-js
Advanced tools
Comparing version 2.0.6 to 2.1.0
@@ -1,7 +0,7 @@ | ||
## [2.0.6](https://github.com/googlemaps/google-maps-services-js/compare/v2.0.5...v2.0.6) (2020-02-28) | ||
# [2.1.0](https://github.com/googlemaps/google-maps-services-js/compare/v2.0.6...v2.1.0) (2020-02-28) | ||
### Bug Fixes | ||
### Features | ||
* deepmerge config ([#343](https://github.com/googlemaps/google-maps-services-js/issues/343)) ([f7ee2c9](https://github.com/googlemaps/google-maps-services-js/commit/f7ee2c962ed95b10fb712d669da7097e3d1d9c44)) | ||
* support passing custom AxiosInstance to client ([#344](https://github.com/googlemaps/google-maps-services-js/issues/344)) ([667cd3a](https://github.com/googlemaps/google-maps-services-js/commit/667cd3ae13df7af25d08ff49d198d532f5cd8699)), closes [#342](https://github.com/googlemaps/google-maps-services-js/issues/342) | ||
@@ -8,0 +8,0 @@ ## [2.0.2](https://github.com/googlemaps/google-maps-services-js/compare/v2.0.1...v2.0.2) (2020-02-08) |
@@ -25,2 +25,5 @@ import { AxiosRequestConfig, AxiosInstance } from "axios"; | ||
export interface ClientOptions { | ||
/** AxiosInstance to be used by client. Provide one of axiosInstance or config. */ | ||
axiosInstance?: AxiosInstance; | ||
/** Config used to create AxiosInstance. Provide one of axiosInstance or config. */ | ||
config?: AxiosRequestConfig; | ||
@@ -32,3 +35,3 @@ experienceId?: string[]; | ||
private experienceId; | ||
constructor({ config, experienceId }: ClientOptions); | ||
constructor({ axiosInstance, config, experienceId }: ClientOptions); | ||
setExperienceId(...ids: string[]): void; | ||
@@ -35,0 +38,0 @@ clearExperienceId(): void; |
@@ -34,4 +34,12 @@ "use strict"; | ||
class Client { | ||
constructor({ config, experienceId }) { | ||
if (config) { | ||
constructor({ axiosInstance, config, experienceId }) { | ||
if (axiosInstance && config) { | ||
throw new Error("Provide one of axiosInstance or config."); | ||
} | ||
if (axiosInstance) { | ||
this.axiosInstance = axiosInstance; | ||
// Avoid changing this instance in any way that affects its behavior | ||
this.axiosInstance.defaults.headers["User-Agent"] = exports.userAgent; | ||
} | ||
else if (config) { | ||
this.axiosInstance = axios_1.default.create(merge(defaultConfig, config)); | ||
@@ -38,0 +46,0 @@ } |
{ | ||
"name": "@googlemaps/google-maps-services-js", | ||
"version": "2.0.6", | ||
"version": "2.1.0", | ||
"description": "Node.js client library for Google Maps API Web Services", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
223981
3297