Skip to content

Commit

Permalink
Replaced axios with fetch
Browse files Browse the repository at this point in the history
Removed axios from package.json. And replaced axios call with fetch call.
  • Loading branch information
jerryren527 committed Nov 1, 2023
1 parent bcf15dc commit e93f61a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
"@babel/runtime": "^7.10.2",
"@sentry/node": "^5.17.0",
"async-exit-hook": "^2.0.1",
"axios": "^1.5.1",
"babel-plugin-module-resolver": "^5.0.0",
"bcryptjs": "^2.4.3",
"body-parser": "^1.18.3",
Expand Down
16 changes: 11 additions & 5 deletions src/controllers/userProfileController.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const moment = require('moment-timezone');

const mongoose = require('mongoose');
const bcrypt = require('bcryptjs');
const axios = require('axios')
const fetch = require("node-fetch");

const moment_ = require('moment');
const jwt = require('jsonwebtoken');
Expand Down Expand Up @@ -142,10 +142,16 @@ const userProfileController = function (UserProfile) {
const url = "https://hgn-rest-beta.azurewebsites.net/api/"
try {
// Log in to Beta login route using provided credentials
let response = await axios.post(url + "login", {
email: email,
password: password
})
const response = await fetch(url + 'login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ email, password }),
});
if (!response.ok) {
throw new Error('Invalid credentials');
}
} catch (error) {
res.status(400).send({
error: 'The actual email or password you provided is incorrect. Please enter the actual email and password associated with your account in the Main HGN app.',
Expand Down

0 comments on commit e93f61a

Please sign in to comment.