Created
July 7, 2016 13:40
-
-
Save franzejr/4b4c8b9dc8fd10a1aca88e6417b0d1ea to your computer and use it in GitHub Desktop.
Fake API JS
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
import axios from 'axios'; | |
const BASE_URL = 'https://fakeApi/api'; | |
const loginUrl = `${BASE_URL}/request_token`; | |
const instance = axios.create({ | |
baseURL: `${BASE_URL}`, | |
}); | |
const Api = { | |
login: function login(email, password) { | |
return instance.post(loginUrl, { | |
email, | |
password, | |
}); | |
}, | |
getContent: function getTopics() { | |
const contentUrl = `${BASE_URL}/content`; | |
return instance.then((inst) => { return inst.get(contentUrl); }); | |
}, | |
}; | |
export default Api; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment