Comparing version 0.0.4 to 0.0.5
@@ -23,4 +23,5 @@ "use strict"; | ||
constructor(options) { | ||
this.baseUrl = "https://azurlane-api.herokuapp.com/v1"; | ||
this.options = options ? options : { userAgent: `AzurLane/v${package_json_1.version} (https://www.npmjs.com/package/azurlane)` }; | ||
this.baseUrl = "https://api.kurozeropb.info/v1/azurlane"; | ||
this.options = options ? options : {}; | ||
this.options.userAgent = (options && options.userAgent) ? options.userAgent : `AzurLane/v${package_json_1.version} (https://www.npmjs.com/package/azurlane)`; | ||
this._axiosOptions = { | ||
@@ -45,4 +46,9 @@ headers: { | ||
catch (error) { | ||
const data = error.response.data; | ||
throw new base_1.ApiError(data); | ||
if (error.response && error.response.data) { | ||
const data = error.response.data; | ||
throw new base_1.ApiError(data); | ||
} | ||
else { | ||
throw error; | ||
} | ||
} | ||
@@ -66,4 +72,9 @@ const data = response.data; | ||
catch (error) { | ||
const data = error.response.data; | ||
throw new base_1.ApiError(data); | ||
if (error.response && error.response.data) { | ||
const data = error.response.data; | ||
throw new base_1.ApiError(data); | ||
} | ||
else { | ||
throw error; | ||
} | ||
} | ||
@@ -70,0 +81,0 @@ const data = response.data; |
{ | ||
"name": "azurlane", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Api wrapper for the azur lane api", | ||
@@ -5,0 +5,0 @@ "main": "dist/lib/index.js", |
@@ -15,7 +15,7 @@ import axios, { AxiosResponse, AxiosRequestConfig } from "axios"; | ||
private _axiosOptions: AxiosRequestConfig; | ||
protected baseUrl: string = "https://azurlane-api.herokuapp.com/v1"; | ||
protected baseUrl: string = "https://api.kurozeropb.info/v1/azurlane"; | ||
public options: IOptions; | ||
/** | ||
* | ||
* | ||
* @param {IOptions} options Constructor options | ||
@@ -25,3 +25,4 @@ * @param {string} [options.userAgent] UA to use when making http requests | ||
public constructor(options?: IOptions) { | ||
this.options = options ? options : { userAgent: `AzurLane/v${version} (https://www.npmjs.com/package/azurlane)` }; | ||
this.options = options ? options : {}; | ||
this.options.userAgent = (options && options.userAgent) ? options.userAgent : `AzurLane/v${version} (https://www.npmjs.com/package/azurlane)` | ||
@@ -37,3 +38,3 @@ this._axiosOptions = { | ||
* Get information about a ship by name | ||
* | ||
* | ||
* @param {string} name The name of the ship | ||
@@ -47,4 +48,8 @@ * @returns {Promise<IShip>} | ||
} catch (error) { | ||
const data: IErrorResponse = error.response.data; | ||
throw new ApiError(data); | ||
if (error.response && error.response.data) { | ||
const data: IErrorResponse = error.response.data; | ||
throw new ApiError(data); | ||
} else { | ||
throw error; | ||
} | ||
} | ||
@@ -58,3 +63,3 @@ | ||
* Get ship names matching the given construction time | ||
* | ||
* | ||
* @param {string} time The construction time | ||
@@ -68,4 +73,8 @@ * @returns {Promise<IConstruction>} | ||
} catch (error) { | ||
const data: IErrorResponse = error.response.data; | ||
throw new ApiError(data); | ||
if (error.response && error.response.data) { | ||
const data: IErrorResponse = error.response.data; | ||
throw new ApiError(data); | ||
} else { | ||
throw error; | ||
} | ||
} | ||
@@ -83,2 +92,2 @@ | ||
// @ts-ignore | ||
export = AzurLane; | ||
export = AzurLane; |
{ | ||
"name": "azurlane", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"description": "Api wrapper for the azur lane api", | ||
@@ -5,0 +5,0 @@ "main": "dist/lib/index.js", |
@@ -6,2 +6,3 @@ const assert = require("assert"); | ||
const azurlane = new AzurLane(); | ||
assert(azurlane instanceof AzurLane, "azurlane did not construct properly"); | ||
@@ -8,0 +9,0 @@ describe("#ship()", function() { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
506255
1596