Last active
March 7, 2019 01:40
-
-
Save jochasinga/16f5d0807a97a77472c38517fbf5fa9d to your computer and use it in GitHub Desktop.
Step one in refactor
This file contains 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
async function postLoginData(data) { | |
const loginUrl = `${apiBaseUrl}/login`; | |
let response = await fetch(loginUrl, { | |
method: "POST", | |
mode: "cors", | |
cache: "no-cache", | |
credentials: "same-origin", | |
headers: { | |
"Content-Type": "application/json; charset=utf-8", | |
}, | |
redirect: "follow", | |
referrer: "no-referrer", | |
body: JSON.stringify(data), | |
}); | |
return response; | |
} | |
// Get the user's data based on user id. | |
async function getUser(userId) { | |
const userUrl = `${apiBaseUrl}/users/${userId}`; | |
let response = await fetch(userUrl, { | |
method: "GET", | |
mode: "cors", | |
cache: "no-cache", | |
credentials: "same-origin", | |
headers: { | |
"Content-Type": "application/json; charset=utf-8", | |
}, | |
redirect: "follow", | |
referrer: "no-referrer", | |
}); | |
return response; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment