Created
August 2, 2018 14:51
-
-
Save juanmav/d85cfc033d487ae0696e34164bb39609 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((response) => { | |
| if (response.ok) { | |
| return updateOlympiaUser(user) | |
| } else { | |
| let error = new OAuthError(OAuthError.OAUTH_UPDATE_USER_ERROR, response.statusText, 'UPDATE USER BY ID'); | |
| throw error; | |
| } | |
| }) | |
| .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; | |
| } | |
| }).then(res => { | |
| console.endTime('', 'OAuthUserUpdate'); | |
| }) | |
| .catch(exception => { | |
| logger.error(exception); | |
| throw exception; | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment