Created
August 1, 2018 20:08
-
-
Save juanmav/b01b94d9d932d937a4c0ff0451fa8bb8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function userUpdate(userId, user, fetch = getFetch()) { | |
| // /api/v1/users/username/eroskisuperclaves/ | |
| // dev.auth.olympiaviajes.es | |
| const url = `http://${process.env.OAUTH_APP_URL}/api/v1/users/${userId}`; | |
| console.initTime('', 'OAuthUserUpdate'); | |
| return fetch(url, { | |
| method: 'PUT', | |
| headers: { | |
| Accept: 'application/json', | |
| 'Content-Type': 'application/json', | |
| }, | |
| body: JSON.stringify(user) | |
| }).then(async (response) => { | |
| if (response.ok) { | |
| await updateOlympiaUser(user).then(b2bresult => { | |
| logger.info(b2bresult); | |
| if (b2bresult.ok) { | |
| return response.json(); | |
| } else { | |
| let error = new B2BWebWSError(B2BWebWSError.UPDATE_USER_ERROR, b2bresult.statusText, 'OLYWEB B2B Update'); | |
| throw error; | |
| } | |
| }).catch(exception => { | |
| logger.error(exception); | |
| throw exception; | |
| }); | |
| } else { | |
| let error = new OAuthError(OAuthError.OAUTH_UPDATE_USER_ERROR, response.statusText, 'UPDATE USER BY ID'); | |
| throw error; | |
| } | |
| }).then(res => { | |
| console.endTime('', 'OAuthUserUpdate'); | |
| } | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment