sync-request-curl
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -64,2 +64,3 @@ "use strict"; | ||
} | ||
url = curl.getInfo('EFFECTIVE_URL').data; | ||
// ======================================================================= // | ||
@@ -91,5 +92,5 @@ // Finalising return | ||
curl.close(); | ||
return { statusCode, headers, body, getBody }; | ||
return { statusCode, headers, body, getBody, url }; | ||
}; | ||
exports.default = request; | ||
//# sourceMappingURL=request.js.map |
@@ -24,2 +24,3 @@ /// <reference types="node" /> | ||
getBody: GetBody; | ||
url: string; | ||
} |
@@ -62,2 +62,3 @@ import { Curl, CurlCode, Easy } from 'node-libcurl'; | ||
} | ||
url = curl.getInfo('EFFECTIVE_URL').data; | ||
// ======================================================================= // | ||
@@ -89,5 +90,5 @@ // Finalising return | ||
curl.close(); | ||
return { statusCode, headers, body, getBody }; | ||
return { statusCode, headers, body, getBody, url }; | ||
}; | ||
export default request; | ||
//# sourceMappingURL=request.js.map |
@@ -24,2 +24,3 @@ /// <reference types="node" /> | ||
getBody: GetBody; | ||
url: string; | ||
} |
@@ -7,3 +7,3 @@ { | ||
}, | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"files": [ | ||
@@ -10,0 +10,0 @@ "dist" |
@@ -64,3 +64,3 @@ # sync-request-curl | ||
Only the following subset of options are supported for the time being: | ||
Only the following subset of options is supported for the time being: | ||
@@ -74,34 +74,46 @@ <table> | ||
<tr> | ||
<td><code>qs</code></td> | ||
<td>An object containing query string values to be appended to the URL.</td> | ||
<td>qs</td> | ||
<td> | ||
An object containing query string parameters which will be appended to the URL. | ||
</td> | ||
<td><code>{ message: 'Hello, world!' }</code></td> | ||
</tr> | ||
<tr> | ||
<td><code>headers</code></td> | ||
<td>HTTP headers to be included in the request.</td> | ||
<td>headers</td> | ||
<td> | ||
HTTP headers for the request. | ||
</td> | ||
<td><code>{ token: 'abcdefg' }</code></td> | ||
</tr> | ||
<tr> | ||
<td><code>json</code></td> | ||
<td>Sets the body as a JSON representation of the value and adds <code>Content-type: application/json</code> header.</td> | ||
<td><code>{ email: 'example@email.com', password: 'comp1531' }</code></td> | ||
<td>json</td> | ||
<td> | ||
Sets the body as a JSON representation of the value and automatically adds <code>Content-type: application/json</code> to the header.</td> | ||
<td> | ||
<code>{ email: 'example@email.com', password: 'comp1531' }</code></td> | ||
</tr> | ||
<tr> | ||
<td><code>body</code></td> | ||
<td>Body for POST and PUT requests. It is recommended to use <code>json</code> instead for JSON payloads.</td> | ||
<td>body</td> | ||
<td> | ||
Body for POST and PUT requests. We recommended using <code>json</code> instead for JSON payloads, otherwise the <code>Content-Type</code> will need to be set manually. | ||
</td> | ||
<td><code>JSON.stringify({ email: 'example@email.com', password: 'comp1531' })</code></td> | ||
</tr> | ||
<tr> | ||
<td><code>timeout</code></td> | ||
<td>Times out if no response is returned within the given number of milliseconds.</td> | ||
<td><code>2000</code></td> | ||
<td>timeout</td> | ||
<td> | ||
Times out if no response is returned within the given number of milliseconds | ||
</td> | ||
<td><code>2000<code></td> | ||
</tr> | ||
<tr> | ||
<td><code>followRedirects</code></td> | ||
<td>Defaults to true, but can be set to false to not follow any redirects (302) automatically</td> | ||
<td>followRedirects</td> | ||
<td> | ||
Defaults to true, but can be set to false to not follow any redirects (302) automatically | ||
</td> | ||
<td><code>false</code></td> | ||
</tr> | ||
<tr> | ||
<td><code>maxRedirects</code></td> | ||
<td>Sets the maximum number of redirects to follow before throwing an Error. Default: <code>Number.MAX_SAFE_INTEGER</code>.</td> | ||
<td>maxRedirects</td> | ||
<td>Sets the maximum number of redirects to follow before throwing an Error. Defaults to <code>NumberMAX_SAFE_INTEGER</code>.</td> | ||
<td><code>3</code></td> | ||
@@ -131,4 +143,5 @@ </tr> | ||
- **`headers`** - HTTP response headers | ||
- **`body`** - a string or buffer - use `body.toString()` for common use cases. | ||
- **`body`** - a string or buffer - use `body.toString()` for common use cases in combination with `JSON.parse()` | ||
- **`getBody`** - a function with an optional `encoding` argument that returns the `body` if `encoding` is `undefined`, otherwise `body.toString(encoding)`. If the `statusCode >= 300`, an `Error` is thrown instead. | ||
- **`url`** - the final URL with query string parameters appended and if any redirection occurred. | ||
@@ -143,2 +156,3 @@ In [src/types.ts](src/types.ts), the following is defined: | ||
getBody: (encoding?: BufferEncoding) => string | Buffer; // simplified | ||
url: string; | ||
} | ||
@@ -145,0 +159,0 @@ ``` |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
30397
313
167