From 5c39f737db212377954ad8fe79a18c8d861b6b14 Mon Sep 17 00:00:00 2001 From: Evan Yang Date: Fri, 1 Sep 2023 22:47:25 -0700 Subject: [PATCH] client/api: update user db email --- client/src/api/UserApiService.js | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/client/src/api/UserApiService.js b/client/src/api/UserApiService.js index 99d17174..d533f9aa 100644 --- a/client/src/api/UserApiService.js +++ b/client/src/api/UserApiService.js @@ -46,13 +46,29 @@ class UserApiService { const requestOptions = { method: 'PATCH', headers: this.headers, - body: JSON.stringify({ isActive }) + body: JSON.stringify({ isActive }), + }; + + try { + return await fetch(url, requestOptions); + } catch (err) { + console.error('update is-active error', err); + alert('server not responding. Please try again.'); } + } + + async updateUserDbEmail(userToEdit, email) { + const url = `${this.baseUserUrl}${userToEdit._id}`; + const requestOptions = { + method: 'PATCH', + headers: this.headers, + body: JSON.stringify({ email }), + }; try { return await fetch(url, requestOptions); } catch (err) { - console.error('update is-active error', err) + console.error('update use email error', err); alert('server not responding. Please try again.'); } }