
Research
Malicious fezbox npm Package Steals Browser Passwords from Cookies via Innovative QR Code Steganographic Technique
A malicious package uses a QR code as steganography in an innovative technique.
@voiceflow/fetch
Advanced tools
Voiceflow fetch wrapper and error handling for SDKs
yarn add --exact @voiceflow/fetch @voiceflow/exception
# if using for Node.JS
yarn add --exact undici
This is a universal library and can be used in the browser or in a Node.JS environment by passing a fetch
implementation.
import { FetchClient } from '@voiceflow/fetch';
const fetch = new FetchClient({
/* config */
});
Make sure to install undici
when using in a Node.JS environment.
yarn add --exact undici
import { FetchClient } from '@voiceflow/fetch/undici';
const fetch = new FetchClient({
/* config */
});
baseURL
(string
): this will be added as a prefix to the URL of all requestsUse the json
option to pass a payload that will be serialized with JSON.stringify
.
This will also automatically add the request header Content-Type: application/json
.
const fetch = new FetchClient();
await fetch.put('http://example.com', {
json: { foo: 'bar' },
});
Use the json()
method attached to the returned promise to resolve a parsed version of the response payload without needing an additional await
.
You can also specify a type for the parsed result, by default the type will be unknown
.
const fetch = new FetchClient();
const result = await fetch.get('http://example.com').json<{ id: number; name: string }>();
Use the appropriate method to set the HTTP method being used in the request.
const fetch = new FetchClient();
fetch.delete('/foo'); // DELETE /foo
fetch.get('/foo'); // GET /foo
fetch.head('/foo'); // HEAD /foo
fetch.patch('/foo'); // PATCH /foo
fetch.post('/foo'); // POST /foo
fetch.put('/foo'); // PUT /foo
Specify a base URL which should be used to build every request.
const fetch = new FetchClient({ baseURL: 'http://example.com/' });
fetch.get('foo'); // GET http://example.com/foo
If you make a request using a URL
instance then the baseURL
option will be ignored.
const fetch = new FetchClient({ baseURL: 'http://example.com/' });
const url = new URL('http://foo.com/bar');
fetch.get(url); // GET http://foo.com/bar
If any non-2xx
HTTP status is returned then a ClientException
from @voiceflow/exception
is thrown.
const fetch = new FetchClient();
try {
await fetch.get('http://example.com'); // return 404
} catch (err) {
err; // ClientException
}
@voiceflow/exception
IntegrationInternal error codes and other error details are automatically extracted from the response payload when a non-2xx
status is returned.
import { ClientException } from '@voiceflow/exception';
const fetch = new FetchClient();
try {
await fetch.get('http://example.com'); // return 404
} catch (err) {
if (ClientException.instanceOf(err)) {
err.errorCode; // ErrorCode | undefined
}
}
Use the raw()
method to bypass all of the features above to access the underlying fetch
interface directly.
fetch
Requestconst fetch = new FetchClient();
const url = new URL('http://example.com');
const request = new Request(url);
const response = await fetch.raw(request); // Response
undici.fetch
Requestimport { URL } from 'node:url';
import * as undici from 'undici';
const fetch = new FetchClient(undici.fetch);
const url = new URL('http://example.com');
const request = new undici.Request(url);
const response = await fetch.raw(request); // undici.Response
FAQs
Voiceflow fetch wrapper and error handling for SDKs
The npm package @voiceflow/fetch receives a total of 2,010 weekly downloads. As such, @voiceflow/fetch popularity was classified as popular.
We found that @voiceflow/fetch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 25 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
A malicious package uses a QR code as steganography in an innovative technique.
Research
/Security News
Socket identified 80 fake candidates targeting engineering roles, including suspected North Korean operators, exposing the new reality of hiring as a security function.
Application Security
/Research
/Security News
Socket detected multiple compromised CrowdStrike npm packages, continuing the "Shai-Hulud" supply chain attack that has now impacted nearly 500 packages.