New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

config-function

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

config-function

A utility atomic function to get config data before sending to api

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

Config-Functions

A utility atomic function to get config data before sending to api

Install

Install with npm:

$ npm install --save config-function

Functions It returns

configFunction()

Returns a normal config to call an api

export const configFunction = () => {
  const config = {
    headers: {
      "Content-Type": "application/json",
    },
  };
  return config;
};

tokenconfigFunction()

A config cunction which requires a bearer token with it

export const tokenconfigFunction = (userInfo) => {
  if (userInfo.token == undefined) {
    return undefined;
  }
  const { token } = userInfo;
  const config = {
    headers: {
      "Content-Type": "application/json",
      Authorization: `Bearer ${token}`,
    },
  };
  return config;
};

reduxConfigFunction()

A config cunction which requires a bearer token with it in redux

export const reduxConfigFunction = (getState) => {
  const {
    userLogin: { data },
  } = getState();
  const config = {
    "Content-Type": "application/json",
    headers: {
      Authorization: `Bearer ${data.token}`,
    },
  };
  return config;
};

Keywords

npm

FAQs

Package last updated on 29 Mar 2022

Did you know?

Socket

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.

Install

Related posts