Skip to content

Instantly share code, notes, and snippets.

@drenther
Created June 17, 2018 18:49
Show Gist options
  • Save drenther/e6faef8b646a43d071b4c33d777446ba to your computer and use it in GitHub Desktop.
Save drenther/e6faef8b646a43d071b4c33d777446ba to your computer and use it in GitHub Desktop.
All the API requests for react-ssr
import axios from 'axios';
const baseUri = 'http://localhost:3002';
export const fetchAllMovies = () =>
axios
.get(`${baseUri}/movies`)
.then(({ data }) => data)
.catch(e => {
console.log(e);
return null;
});
export const fetchMovieById = id =>
axios
.get(`${baseUri}/movie/${id}`)
.then(({ data }) => data)
.catch(e => {
console.warn(e);
return null;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment