Guest User

Untitled

a guest
Feb 18th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. constructor(props) {
  2. super(props);
  3. this.state = { displayData: [] };
  4. }
  5. async componentDidMount() {
  6. await this.props.getRoadmapByUser({
  7. user_id: this.props.location.pathname.slice(9)
  8. });
  9. this.setState({
  10. displayData: this.props.auth.other_author_created_roadmaps
  11. });
  12.  
  13. }
  14.  
  15. async componentDidMount() {
  16. await this.props.getRoadmapByUser({
  17. user_id: this.props.location.pathname.slice(9)
  18. });
  19. }
  20.  
  21. export const getRoadmapByUser = id => dispatch => {
  22. return axios
  23. .post("/api/users/getroadmapbyuser", id)
  24. .then(res => dispatch({ type: GET_ROADMAPS_BY_USER, payload: res.data }));
  25. };
  26.  
  27. router.post("/getroadmapbyuser", (req, res) => {
  28. User.findOne({ _id: req.body.user_id }).then(user =>
  29. res.json(user.createdRoadmap)
  30. );
  31. });
  32.  
  33. case GET_ROADMAPS_BY_USER:
  34. return {
  35. ...state,
  36. other_author_created_roadmaps: action.payload
  37. };
Add Comment
Please, Sign In to add comment