atomicassets
Advanced tools
Comparing version 0.9.0 to 0.9.1
import ExplorerActionGenerator from '../../Actions/Explorer'; | ||
import { ApiAsset, ApiCollection, ApiConfig, ApiLog, ApiOffer, ApiSchema, ApiSchemaStats, ApiTemplate, ApiTemplateStats, ApiTransfer } from './types'; | ||
import { ApiAsset, ApiCollection, ApiConfig, ApiLog, ApiOffer, ApiSchema, ApiSchemaStats, ApiTemplate, ApiTemplateStats, ApiTransfer } from './Types'; | ||
declare type Fetch = (input?: Request | string, init?: RequestInit) => Promise<Response>; | ||
@@ -4,0 +4,0 @@ declare type ApiArgs = { |
@@ -7,3 +7,3 @@ "use strict"; | ||
const Explorer_1 = __importDefault(require("../../Actions/Explorer")); | ||
const ExplorerError_1 = __importDefault(require("../../Errors/ExplorerError")); | ||
const ApiError_1 = __importDefault(require("../../Errors/ApiError")); | ||
class ExplorerApi { | ||
@@ -87,22 +87,18 @@ constructor(endpoint, namespace, args) { | ||
let response; | ||
let json = null; | ||
const f = this.fetchBuiltin; | ||
const queryString = Object.keys(args).map((key) => { | ||
return key + '=' + encodeURIComponent(args[key]); | ||
}).join('&'); | ||
try { | ||
const f = this.fetchBuiltin; | ||
const queryString = Object.keys(args).map((key) => { | ||
return key + '=' + encodeURIComponent(args[key]); | ||
}).join('&'); | ||
response = await f(this.endpoint + '/' + this.namespace + path + (queryString.length > 0 ? '?' + queryString : '')); | ||
if (response.status === 200) { | ||
json = await response.json(); | ||
} | ||
} | ||
catch (e) { | ||
e.isFetchError = true; | ||
throw e; | ||
throw new ApiError_1.default(e.message, 500); | ||
} | ||
if (json === null) { | ||
throw new Error('Invalid status code received'); | ||
const json = await response.json(); | ||
if (response.status !== 200) { | ||
throw new ApiError_1.default(json.message, response.status); | ||
} | ||
if (!json.success) { | ||
throw new ExplorerError_1.default(json.message); | ||
throw new ApiError_1.default(json.message, response.status); | ||
} | ||
@@ -109,0 +105,0 @@ return json.data; |
@@ -12,3 +12,3 @@ { | ||
"license": "MIT", | ||
"version": "0.9.0", | ||
"version": "0.9.1", | ||
"main": "build/index.js", | ||
@@ -20,2 +20,3 @@ "types": "build/index.d.ts", | ||
"build:web": "webpack --config webpack.prod.js", | ||
"build": "yarn run build:npm && yarn run build:web", | ||
"lint": "tslint -p tsconfig.json", | ||
@@ -22,0 +23,0 @@ "test": "mocha -r ts-node/register test/**/*.test.ts" |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
138334
86
3087