From eb1e0ad011213cb3bf66aa353cd08e3883cf53a2 Mon Sep 17 00:00:00 2001 From: Archan Banerjee Date: Sat, 16 Oct 2021 15:29:53 +0530 Subject: [PATCH] v1.0.1 --- README.md | 16 ++++++++++------ index.js | 17 +++++++++++++++++ 2 files changed, 27 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index d5bafe5..d28f7fd 100644 --- a/README.md +++ b/README.md @@ -1,13 +1,17 @@ -# Axios-Config (https://www.npmjs.com/package/axios-config) +# Npm-Axios-Config ## A npm package for Reactjs, to handle config variables while making any request using axios. -## About axios-config: +## About npm-axios-config: This function takes two arguments. The first one is the type of the - config variable user want. If user wants to pass a bearer token, then + config variable user want. If user wants to pass a "bearer token", then he or she must have to pass "privBearerConfig" as the first argument - and the "token" as the second argument. Else the user will get a simple - config variable that can be used for login or registration. + and the "token" as the second argument. If user wants to upload any file + without token, user have to pass only "pubMultConfig" as argument. + Else if user wants to upload any file with token, user must have to pass + "privMultConfig" as the first argument, and the "token" as the second argument. + Else the user will get a simple config variable that can be used for + login or registration. ## How to install? - Open the terminal. Just type "npm i axios-config" and hit enter. \ No newline at end of file + Open the terminal. Just type "npm i npm-axios-config" and hit enter. \ No newline at end of file diff --git a/index.js b/index.js index 62a4c0c..8865904 100644 --- a/index.js +++ b/index.js @@ -13,6 +13,17 @@ const axiosConfig = (type, token) => { "Content-Type": "application/json", Authorization: `Bearer ${token}`, } + }, + { + headers: { + 'Content-Type': 'multipart/form-data' + } + }, + { + headers: { + 'Content-Type': 'multipart/form-data', + Authorization: `Bearer ${token}`, + } } ] @@ -24,6 +35,12 @@ const axiosConfig = (type, token) => { case "privBearerConfig": configInd = 1; break; + case "pubMultConfig": + configInd = 2; + break; + case "privMultConfig": + configInd = 3; + break; default: break; }