@@ -54,30 +54,25 @@ api.interceptors.response.use(
5454
5555// Inscription
5656export const registerUser = async ( userData : any ) =>
57- await api . post ( `${ API_URL } register/` , userData )
57+ await api . post ( `register/` , userData )
5858
5959// Connexion
6060export const loginUser = async ( credentials : {
6161 email : string
6262 password : string
6363} ) => {
64- const response = await api . post < LoginResponse > (
65- `${ API_URL } login/` ,
66- credentials
67- )
64+ const response = await api . post < LoginResponse > ( `login/` , credentials )
6865 return response . data
6966}
7067
7168// Déconnexion
7269export const logoutUser = async ( ) => {
73- await api . post ( `${ API_URL } logout/` )
70+ await api . post ( `logout/` )
7471}
7572
7673export const checkAuthentication = async ( ) => {
7774 try {
78- const response = await api . get ( `${ API_URL } check-authentication/` , {
79- withCredentials : true ,
80- } )
75+ const response = await api . get ( "check-authentication/" )
8176 return response . data . authenticated
8277 } catch {
8378 return false
@@ -86,28 +81,25 @@ export const checkAuthentication = async () => {
8681
8782// Update du profil
8883export const updateProfile = async ( userData : any ) => {
89- const response = await api . patch ( `${ API_URL } profile/` , userData , {
90- withCredentials : true ,
91- } )
84+ const response = await api . patch ( "profile/" , userData )
9285 return response . data
9386}
9487
9588// Suppression du compte
96- export const deleteAccount = async ( ) =>
97- await api . delete ( `${ API_URL } delete-account/` , { withCredentials : true } )
89+ export const deleteAccount = async ( ) => await api . delete ( "delete-account/" )
9890
9991// Envoi de code de vérification selon un contexte
10092export const sendVerificationCode = async (
10193 email : string ,
10294 context : "registration" | "reset-password"
103- ) => await api . post ( `${ API_URL } send-code-${ context } /` , { email } )
95+ ) => await api . post ( `send-code-${ context } /` , { email } )
10496
10597// Verifier le code
10698export const verifyCode = async (
10799 email : string ,
108100 code : string
109101) : Promise < VerifyCodeResponse > => {
110- const response = await api . post ( ` ${ API_URL } verify-code/` , {
102+ const response = await api . post ( " verify-code/" , {
111103 email,
112104 code,
113105 } )
@@ -116,7 +108,7 @@ export const verifyCode = async (
116108
117109// Réinitialiser le mot de passe
118110export const resetPassword = async ( email : string , password : string ) => {
119- const response = await api . post ( ` ${ API_URL } reset-password/` , {
111+ const response = await api . post ( " reset-password/" , {
120112 email,
121113 password,
122114 } )
@@ -135,9 +127,7 @@ export const calculateCalories = async (payload: {
135127 goal : string | null
136128} ) : Promise < CaloriesResponse > => {
137129 try {
138- const response = await api . post ( `${ API_URL } calculate-calories/` , payload , {
139- withCredentials : true ,
140- } )
130+ const response = await api . post ( "calculate-calories/" , payload )
141131 return response . data
142132 } catch ( error ) {
143133 throw error
@@ -149,7 +139,7 @@ export const calculateCalories = async (payload: {
149139//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
150140export const getProgressRecords = async ( ) : Promise < ProgressRecord [ ] > => {
151141 try {
152- const response = await axios . get ( ` ${ API_URL } progress-records/` )
142+ const response = await api . get ( " progress-records/" )
153143 return response . data
154144 } catch ( error ) {
155145 throw error
@@ -161,11 +151,7 @@ export const updateRecord = async (
161151 payload : Record < string , any >
162152) : Promise < ProgressRecord > => {
163153 try {
164- const response = await axios . patch (
165- `${ API_URL } progress-records/${ id } /` ,
166- payload ,
167- { withCredentials : true }
168- )
154+ const response = await api . patch ( `progress-records/${ id } /` , payload )
169155 return response . data
170156 } catch ( error ) {
171157 throw error
@@ -174,9 +160,7 @@ export const updateRecord = async (
174160
175161export const deleteRecord = async ( id : number ) => {
176162 try {
177- await axios . delete ( `${ API_URL } progress-records/${ id } /` , {
178- withCredentials : true ,
179- } )
163+ await api . delete ( `progress-records/${ id } /` )
180164 } catch ( error ) {
181165 throw error
182166 }
0 commit comments