
Research
/Security News
Critical Vulnerability in NestJS Devtools: Localhost RCE via Sandbox Escape
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
@samatech/fetch-api
Advanced tools
Small fetch wrapper for creating quick API wrappers
npm i -D @samatech/fetch-api
yarn add @samatech/fetch-api
pnpm i -D @samatech/fetch-api
FetchApi
global configuration is passed to the constructor.
FetchApi({
// API base URL prepended to requests
baseUrl: '',
// Default request timeout
timeout: 10000,
// Passed to JSON.stringify and used as fetch `body`.
// Sets headers: { Accept: 'application/json', 'Content-Type': 'application/json' }
data: null,
// Request URL parameters, e.g. `{ 'a': 1 }`. Passed to `new URLSearchParams(params)`
// Entries with undefined values are filtered out
params: RequestParams,
// Convenience for Basic Auth.
// Sets headers['Authorization'] = `Basic ${btoa(`${auth.username}:${auth.password}`)}`
auth: { username: 'test', password: 'password' }
// Request interceptors
requestInterceptors: [],
// Response interceptors
responseInterceptors: [],
});
Here is an example of basic usage that includes a response interceptor for handling 403 response codes and converting the body to json.
const api = new FetchApi({
baseUrl: 'https://cool.api/',
responseInterceptors: [
async (res) => {
const { status } = res;
if (status === 403) {
throw new Error('FORBIDDEN');
}
res.data = await res.json();
return res;
},
],
});
// Make a get request to 'https://cool.api/status/'
const status = api.request({ url: 'status/' });
fetch
must be available. If you need to support older browsers or Node, use a polyfill such as whatwg-fetch
See the example
directory.
MIT License © 2021 Samuel Pullman
FAQs
Small fetch wrapper for quickly prototyping API clients
The npm package @samatech/fetch-api receives a total of 0 weekly downloads. As such, @samatech/fetch-api popularity was classified as not popular.
We found that @samatech/fetch-api demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
/Security News
A flawed sandbox in @nestjs/devtools-integration lets attackers run code on your machine via CSRF, leading to full Remote Code Execution (RCE).
Product
Customize license detection with Socket’s new license overlays: gain control, reduce noise, and handle edge cases with precision.
Product
Socket now supports Rust and Cargo, offering package search for all users and experimental SBOM generation for enterprise projects.