
Security News
Axios Supply Chain Attack Reaches OpenAI macOS Signing Pipeline, Forces Certificate Rotation
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.
fredux-api-utils
Advanced tools
This library provides a set of functions which build http requests. This library relies on the standard fetch api, and should be polyfilled in older browsers.
npm install --save fredux-api-utils
To send some URL params:
import { get } from "fredux-api-utils";
get("/users", { params: { key1: "value1", key2: ["value2", "value3"] } })
.then(response => console.log(response))
.catch(error => console.log(error));
To send an object as the JSON body:
import { post } from "fredux-api-utils";
post("/users", { body: {name: "Peter"} })
.then(response => console.log(response))
.catch(error => console.log(error));
To send form data as the body:
import { post } from "fredux-api-utils";
post("/users", { formData: { key1: "value1", key2: ["value2", "value3"] } })
.then(response => console.log(response))
.catch(error => console.log(error));
To send form data as FormData object:
import { post } from "fredux-api-utils";
const formData = new FormData();
formData.append("name", "My Name");
formData.append("file", new Blob(["Some notes..."], { type: "text/plain" }));
// If there's not a Content-Type header, will use multipart/form-data
post("/users", { formData })
.then(response => console.log(response))
.catch(error => console.log(error));
To add some headers:
import { post } from "fredux-api-utils";
post("/users", { headers: { "my-custom-header": "custom" } })
.then(response => console.log(response))
.catch(error => console.log(error));
NOTE: when passing a body option, Content-Type: application/json will always be set unless you explicitely pass
a Content-Type. The same goes with formData and Content-Type: x-www-form-urlencoded unless you pass
a FormData object. In this case, Content-Type: multipart/form-data will be set automatically as default (you
can override it anyway).
To set several other options just pass them:
import { get } from "fredux-api-utils";
get("/users", { timeout: 2000, mode: "no-cors" })
.then(response => console.log(response))
.catch(error => console.log(error));
get(endpoint, options)post(endpoint, options)put(endpoint, options)patch(endpoint, options)del(endpoint, options)Where endpoint is a string with the resource you wish to fetch and options is an
object containing custom settings you want to apply to the request. The possible options are:
body: any JSON body.formData: any data to be passed as a x-www-form-urlencoded object or a FormData instance.params: an object containing query params.headers: any headers you want to add to your request.timeout: any timeout in milliseconds. The default is 0.credentials: sets the policy for sending cookies. One of omit, same-origin, or include. Using same-origin as default.mode: the mode you want to use for the request, e.g., cors, no-cors, same-origin, or navigate. Defaults to cors.redirect: the redirect mode to use, e.g. follow, error, or manual. Defaults to follow.referrer: the referrer of the request, Defaults to client.cache: cache mode for the request, e.g. default, no-store, reload, no-cache, force-cache,only-if-cached. Defaults to default.This options, for the most part adhere to the fetch Request API.
FAQs
fabulous redux api utils
The npm package fredux-api-utils receives a total of 19 weekly downloads. As such, fredux-api-utils popularity was classified as not popular.
We found that fredux-api-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer 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
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.

Security News
Open source is under attack because of how much value it creates. It has been the foundation of every major software innovation for the last three decades. This is not the time to walk away from it.

Security News
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.