Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const User = {
- getPassword() {
- return new Promise(resolve => {
- setTimeout(resolve, 100, "foo");
- });
- }
- };
- const userInfoURL = "/";
- class Example {
- static async login() {
- let password = await User.getPassword();
- alert(password); // this works, password is shown
- return fetch(userInfoURL, {
- method: 'GET',
- headers: {
- 'Authorization': password,
- 'Content-Type': 'application/json'
- }
- })
- }
- }
- Example.login()
- .then(response => response.json())
- .then(data => { console.log("worked", data); })
- .catch(err => { console.error("failed", err); });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement