@percy/client
Advanced tools
Comparing version 1.0.0-beta.75 to 1.0.0-beta.76
@@ -116,4 +116,4 @@ "use strict"; | ||
return (0, _request.default)(`${this.apiUrl}/${path}`, { | ||
method: 'GET', | ||
headers: this.headers() | ||
headers: this.headers(), | ||
method: 'GET' | ||
}); | ||
@@ -125,7 +125,7 @@ } // Performs a POST request to a JSON API endpoint with appropriate headers. | ||
return (0, _request.default)(`${this.apiUrl}/${path}`, { | ||
method: 'POST', | ||
body: JSON.stringify(body), | ||
headers: this.headers({ | ||
'Content-Type': 'application/vnd.api+json' | ||
}) | ||
}), | ||
method: 'POST', | ||
body | ||
}); | ||
@@ -132,0 +132,0 @@ } // Creates a build with optional build resources. Only one build can be |
@@ -220,5 +220,7 @@ "use strict"; | ||
// accept `request(url, callback)` | ||
if (typeof options === 'function') [options, callback] = [{}, options]; | ||
if (typeof options === 'function') [options, callback] = [{}, options]; // gather request options | ||
let { | ||
body, | ||
headers, | ||
retries, | ||
@@ -229,6 +231,3 @@ retryNotFound, | ||
...requestOptions | ||
} = options; // allow bypassing proxied requests entirely | ||
if (!noProxy) requestOptions.agent || (requestOptions.agent = proxyAgentFor(url)); // parse the requested URL into request options | ||
} = options; | ||
let { | ||
@@ -241,3 +240,21 @@ protocol, | ||
hash | ||
} = new URL(url); | ||
} = new URL(url); // automatically stringify body content | ||
if (body && typeof body !== 'string') { | ||
headers = { | ||
'Content-Type': 'application/json', | ||
...headers | ||
}; | ||
body = JSON.stringify(body); | ||
} // combine request options | ||
Object.assign(requestOptions, { | ||
agent: requestOptions.agent || !noProxy && proxyAgentFor(url) || null, | ||
path: pathname + search + hash, | ||
protocol, | ||
hostname, | ||
headers, | ||
port | ||
}); | ||
return (0, _utils.retry)((resolve, reject, retry) => { | ||
@@ -248,3 +265,3 @@ let handleError = error => { | ||
let shouldRetry = error.response // maybe retry 404s and always retry 500s | ||
? retryNotFound && error.response.status === 404 || error.response.status >= 500 && error.response.status < 600 // retry specific error codes | ||
? retryNotFound && error.response.statusCode === 404 || error.response.statusCode >= 500 && error.response.statusCode < 600 // retry specific error codes | ||
: !!error.code && RETRY_ERROR_CODES.includes(error.code); | ||
@@ -276,3 +293,4 @@ return shouldRetry ? retry(error) : reject(error); | ||
response: { | ||
status: res.statusCode, | ||
statusCode: res.statusCode, | ||
headers: res.headers, | ||
body | ||
@@ -292,8 +310,3 @@ } | ||
let req = (protocol === 'https:' ? _https.default : _http.default).request({ ...requestOptions, | ||
path: pathname + search + hash, | ||
protocol, | ||
hostname, | ||
port | ||
}); | ||
let req = (protocol === 'https:' ? _https.default : _http.default).request(requestOptions); | ||
req.on('response', handleResponse); | ||
@@ -300,0 +313,0 @@ req.on('error', handleError); |
{ | ||
"name": "@percy/client", | ||
"version": "1.0.0-beta.75", | ||
"version": "1.0.0-beta.76", | ||
"license": "MIT", | ||
@@ -28,4 +28,4 @@ "repository": { | ||
"dependencies": { | ||
"@percy/env": "1.0.0-beta.75", | ||
"@percy/logger": "1.0.0-beta.75" | ||
"@percy/env": "1.0.0-beta.76", | ||
"@percy/logger": "1.0.0-beta.76" | ||
}, | ||
@@ -35,3 +35,3 @@ "devDependencies": { | ||
}, | ||
"gitHead": "3b778a9c0b72dcbf113910227f1a073a2714042a" | ||
"gitHead": "445af68d8e270e2a35fc74e26422ed5d3c91d2ae" | ||
} |
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
35376
720
+ Added@percy/env@1.0.0-beta.76(transitive)
+ Added@percy/logger@1.0.0-beta.76(transitive)
- Removed@percy/env@1.0.0-beta.75(transitive)
- Removed@percy/logger@1.0.0-beta.75(transitive)
Updated@percy/env@1.0.0-beta.76
Updated@percy/logger@1.0.0-beta.76