Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
@algolia/requester-fetch
Advanced tools
@algolia/requester-fetch is a lightweight HTTP client built on top of the Fetch API. It is designed to be used with Algolia's JavaScript API clients but can be used independently for making HTTP requests in a straightforward manner.
Basic GET Request
This feature allows you to make a basic GET request to a specified URL. The response is returned as a promise, which can be handled using `.then` and `.catch`.
const { createFetchRequester } = require('@algolia/requester-fetch');
const requester = createFetchRequester();
requester({
method: 'GET',
url: 'https://jsonplaceholder.typicode.com/posts/1'
}).then(response => {
console.log(response.content);
}).catch(error => {
console.error(error);
});
POST Request with JSON Body
This feature allows you to make a POST request with a JSON body. You can specify the request method, URL, data, and headers.
const { createFetchRequester } = require('@algolia/requester-fetch');
const requester = createFetchRequester();
requester({
method: 'POST',
url: 'https://jsonplaceholder.typicode.com/posts',
data: JSON.stringify({
title: 'foo',
body: 'bar',
userId: 1
}),
headers: {
'Content-type': 'application/json; charset=UTF-8'
}
}).then(response => {
console.log(response.content);
}).catch(error => {
console.error(error);
});
Handling Response Headers
This feature allows you to access and handle response headers from the HTTP response. The headers can be accessed using the `.headers` property of the response object.
const { createFetchRequester } = require('@algolia/requester-fetch');
const requester = createFetchRequester();
requester({
method: 'GET',
url: 'https://jsonplaceholder.typicode.com/posts/1'
}).then(response => {
console.log(response.headers.get('Content-Type'));
}).catch(error => {
console.error(error);
});
Axios is a promise-based HTTP client for the browser and Node.js. It provides a more feature-rich API compared to @algolia/requester-fetch, including request and response interceptors, automatic JSON data transformation, and support for older browsers.
Node-fetch is a lightweight module that brings `window.fetch` to Node.js. It is similar to @algolia/requester-fetch in that it is built on top of the Fetch API, but it is more focused on providing a polyfill for the Fetch API in Node.js environments.
Got is a human-friendly and powerful HTTP request library for Node.js. It offers a more extensive set of features compared to @algolia/requester-fetch, including retry mechanisms, advanced stream support, and hooks for modifying requests and responses.
nb_api_calls
in getLogs
response is optional (#4142) by @shortcutsconsequence
is required when saving rules (#4146) by @shortcutssaveRule
response type (#4170) by @shortcutsFAQs
Promise-based request library using Fetch.
The npm package @algolia/requester-fetch receives a total of 266,038 weekly downloads. As such, @algolia/requester-fetch popularity was classified as popular.
We found that @algolia/requester-fetch demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 85 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.