Created
November 27, 2018 17:50
-
-
Save larien/f77055783f75159b26b9da58b9376781 to your computer and use it in GitHub Desktop.
actions
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 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