Advertisement
zashkurka

getUserEmail

May 10th, 2023 (edited)
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 0.50 KB | Source Code | 0 0
  1. function getUserEmail() {
  2.   return getStorageValue('apiHost'
  3.   ).then(function (result) {
  4.     return fetch(result.apiHost + 'api/get_user_email',
  5.       {credentials:'include'}
  6.     ).then(function (response) {
  7.       if (response.ok) {
  8.         return response.json()
  9.       }
  10.       return response.json().then(function (json) {
  11.         throw json
  12.       });
  13.     }).then(function (data) {
  14.       return data.user_email
  15.     }
  16.     ).catch(function (error) {
  17.       console.warn(error)
  18.     });
  19.   });
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement