@@ -4,12 +4,13 @@ import { setAuthToken } from '../utils/setAuthToken';
44import jwt_decode from 'jwt-decode' ;
55import { errorHandler } from '../utils/errorHandler' ;
66import { setRequestStatus } from '../utils/setRequestStatus' ;
7+ import { BASE_URL } from './baseApi' ;
78let forgotPasswordToken = "" ;
89
910// to register user
1011export const registerUser = ( userInfo , history ) => async ( dispatch ) => {
1112 try {
12- const res = await axios . post ( ' /user' , userInfo ) ;
13+ const res = await axios . post ( ` ${ BASE_URL } /user` , userInfo ) ;
1314 dispatch ( setRequestStatus ( false ) ) ;
1415
1516 if ( res . status === 201 ) {
@@ -31,8 +32,8 @@ export const loginUser = (userInfo, history) => async (dispatch) => {
3132 try {
3233
3334 console . log ( "LOGGING IN..." , userInfo ) ;
34-
35- const res = await axios . post ( ' /auth/login' , userInfo ) ;
35+ console . log ( 'base url ' , BASE_URL ) ;
36+ const res = await axios . post ( ` ${ BASE_URL } /auth/login` , userInfo ) ;
3637 dispatch ( setRequestStatus ( false ) ) ;
3738 if ( res . status === 200 ) {
3839
@@ -68,7 +69,7 @@ export const loginUser = (userInfo, history) => async (dispatch) => {
6869// forgot password
6970export const forgotPassword = ( email ) => async ( dispatch ) => {
7071 try {
71- const res = await axios . patch ( ' /user/password_reset/request/' , email ) ;
72+ const res = await axios . patch ( ` ${ BASE_URL } /user/password_reset/request/` , email ) ;
7273 dispatch ( setRequestStatus ( false ) ) ;
7374
7475 if ( res . status === 200 ) {
@@ -89,7 +90,10 @@ export const forgotPassword = (email) => async (dispatch) => {
8990// update password
9091export const changePassword = ( passObj ) => async ( dispatch ) => {
9192 try {
92- const res = await axios . patch ( `/user/password_reset/${ forgotPasswordToken } ` , passObj ) ;
93+ const res = await axios . patch (
94+ `${ BASE_URL } /user/password_reset/${ forgotPasswordToken } ` ,
95+ passObj
96+ ) ;
9397 dispatch ( setRequestStatus ( false ) ) ;
9498
9599 if ( res . status === 200 ) {
@@ -113,7 +117,7 @@ export const logoutUser = () => async (dispatch) => {
113117 try {
114118 console . log ( 'Logging out!!' )
115119 // clear token from backend
116- const res = await axios . post ( ' /user/logout' )
120+ const res = await axios . post ( ` ${ BASE_URL } /user/logout` )
117121 if ( res . status === 200 ) {
118122 // remove all keys from the localStorage except the orgId
119123 const orgId = localStorage . getItem ( 'orgId' ) ;
0 commit comments