Skip to content

Instantly share code, notes, and snippets.

@franzejr
Created July 7, 2016 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save franzejr/4b4c8b9dc8fd10a1aca88e6417b0d1ea to your computer and use it in GitHub Desktop.
Save franzejr/4b4c8b9dc8fd10a1aca88e6417b0d1ea to your computer and use it in GitHub Desktop.
Fake API JS
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