Adding code for update password api
This commit is contained in:
@@ -37,4 +37,28 @@ export const userApi = {
|
|||||||
throw new Error('Error logging in');
|
throw new Error('Error logging in');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
update_password: async (userId, currentPassword, updatedPassword, confirmedPassword) => {
|
||||||
|
const request = {
|
||||||
|
user_id: userId,
|
||||||
|
current_password: currentPassword,
|
||||||
|
updated_password: updatedPassword,
|
||||||
|
confirmed_password: confirmedPassword,
|
||||||
|
};
|
||||||
|
|
||||||
|
const reponse = await fetch(
|
||||||
|
`${AUTH_API_BASE_URL}/api/v1/user/password/update`,
|
||||||
|
{
|
||||||
|
method: 'PATCH',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify(request)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
if (reponse.ok) {
|
||||||
|
return reponse.json();
|
||||||
|
} else {
|
||||||
|
throw new Error('Error logging in');
|
||||||
|
}
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user