@skycatch/node-skyapi-sdk
Advanced tools
Comparing version 1.5.0 to 1.6.0
@@ -15,3 +15,3 @@ 'use strict' | ||
)(), | ||
request: ({method, url, headers, body}) => { | ||
request: ({requestId, method, url, headers, body}) => { | ||
if (!/@skycatch\//.test(process.env.DEBUG)) { | ||
@@ -28,3 +28,3 @@ return | ||
'skyapi-sdk-request': { | ||
method, url, headers, body: body ? JSON.parse(body) : undefined | ||
requestId, method, url, headers, body: body ? JSON.parse(body) : undefined | ||
} | ||
@@ -34,3 +34,3 @@ })) | ||
}, | ||
response: ({res, body}) => { | ||
response: ({requestId, res, body}) => { | ||
if (!/@skycatch\//.test(process.env.DEBUG)) { | ||
@@ -47,2 +47,3 @@ return | ||
'skyapi-sdk-response': { | ||
requestId, | ||
status: `${res.status} ${res.statusText}`, | ||
@@ -97,3 +98,3 @@ headers: print.headers(res), | ||
api.request = async ({method, path, query, body, security, options}) => { | ||
api.request = async ({method, path, query, body, security, options = {}}) => { | ||
let headers = {} | ||
@@ -132,8 +133,10 @@ | ||
const url = (origin || `https://${domain}`) + path | ||
const requestId = options.requestId | ||
delete options.requestId | ||
options = {...options, method, headers, body} | ||
print.request({url, method, headers, body}) | ||
print.request({requestId, url, method, headers, body}) | ||
const res = await fetch(url, options) | ||
const json = await res.json() | ||
print.response({res, body: json}) | ||
print.response({requestId, res, body: json}) | ||
@@ -140,0 +143,0 @@ if (/^(4|5)/.test(res.status)) { |
@@ -16,2 +16,3 @@ 'use strict' | ||
request: ({ | ||
requestId, | ||
method, | ||
@@ -32,2 +33,3 @@ url, | ||
'skyapi-sdk-request': { | ||
requestId, | ||
method, | ||
@@ -42,2 +44,3 @@ url, | ||
response: ({ | ||
requestId, | ||
res, | ||
@@ -56,2 +59,3 @@ body | ||
'skyapi-sdk-response': { | ||
requestId, | ||
status: `${res.status} ${res.statusText}`, | ||
@@ -134,3 +138,3 @@ headers: print.headers(res), | ||
security, | ||
options | ||
options = {} | ||
}) => { | ||
@@ -173,2 +177,4 @@ let headers = {} | ||
const url = (origin || `https://${domain}`) + path | ||
const requestId = options.requestId | ||
delete options.requestId | ||
options = { | ||
@@ -182,2 +188,3 @@ ...options, | ||
print.request({ | ||
requestId, | ||
url, | ||
@@ -191,2 +198,3 @@ method, | ||
print.response({ | ||
requestId, | ||
res, | ||
@@ -193,0 +201,0 @@ body: json |
{ | ||
"name": "@skycatch/node-skyapi-sdk", | ||
"version": "1.5.0", | ||
"version": "1.6.0", | ||
"description": "Node SDK to interact with SkyAPI", | ||
@@ -5,0 +5,0 @@ "main": "./dist/skyapi.js", |
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
494139
10296