From 43dff00cd6510493a1a3c649a46e47e58ebd6add Mon Sep 17 00:00:00 2001 From: Alex Holliday Date: Thu, 29 Aug 2024 12:58:32 -0700 Subject: [PATCH] Use axios directly for fetching file --- Client/src/Features/Auth/authSlice.js | 4 ++-- Client/src/Utils/NetworkService.js | 1 - Server/db/mongo/modules/userModule.js | 1 - 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Client/src/Features/Auth/authSlice.js b/Client/src/Features/Auth/authSlice.js index fa1f0471e..f12758715 100644 --- a/Client/src/Features/Auth/authSlice.js +++ b/Client/src/Features/Auth/authSlice.js @@ -1,6 +1,7 @@ import { networkService } from "../../main"; import { createAsyncThunk, createSlice } from "@reduxjs/toolkit"; import { jwtDecode } from "jwt-decode"; +import axios from "axios"; const initialState = { isLoading: false, @@ -57,9 +58,8 @@ export const update = createAsyncThunk( form.password && fd.append("password", form.password); form.newPassword && fd.append("newPassword", form.newPassword); if (form.file && form.file !== "") { - const imageResult = await networkService.get(form.file, { + const imageResult = await axios.get(form.file, { responseType: "blob", - baseURL: "", }); fd.append("profileImage", imageResult.data); } diff --git a/Client/src/Utils/NetworkService.js b/Client/src/Utils/NetworkService.js index c375fade4..b6e8f9a0b 100644 --- a/Client/src/Utils/NetworkService.js +++ b/Client/src/Utils/NetworkService.js @@ -226,7 +226,6 @@ class NetworkService { return this.axiosInstance.put(`/auth/user/${userId}`, form, { headers: { Authorization: `Bearer ${authToken}`, - "Content-Type": "application/json", }, }); } diff --git a/Server/db/mongo/modules/userModule.js b/Server/db/mongo/modules/userModule.js index d29c1889b..1a5c19f36 100644 --- a/Server/db/mongo/modules/userModule.js +++ b/Server/db/mongo/modules/userModule.js @@ -89,7 +89,6 @@ const getUserByEmail = async (email) => { const updateUser = async (req, res) => { const candidateUserId = req.params.userId; - try { const candidateUser = { ...req.body }; // ******************************************