Skip to content

Instantly share code, notes, and snippets.

@larien
Created November 27, 2018 17:50
Show Gist options
  • Save larien/f77055783f75159b26b9da58b9376781 to your computer and use it in GitHub Desktop.
Save larien/f77055783f75159b26b9da58b9376781 to your computer and use it in GitHub Desktop.
actions
import axios from 'axios';
const url = process.env.NODE_ENV === 'production' ? "/api/v1/" : "http://localhost:8080/api/v1/"
export function loadReviews(){
return(dispatch) => {
axios.get(`${url}reviews`)
.then((res)=> {
let reviews = res.data
dispatch({type: 'LOAD_REVIEWS', reviews})
}).catch((err) => console.log(err))
}
}
export function getReview(review_id) {
return(dispatch) => {
axios.get(`${url}reviews/${review_id}`)
.then((res) => {
let review = res.data
dispatch({ type: 'VIEW_REVIEW', review})
}).catch((err => console.log(err)))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment