Skip to content

Instantly share code, notes, and snippets.

@LanguidSquid
Created October 25, 2017 22:46
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 LanguidSquid/beb0b1a11f4043156bb8828d4f71292c to your computer and use it in GitHub Desktop.
Save LanguidSquid/beb0b1a11f4043156bb8828d4f71292c to your computer and use it in GitHub Desktop.
here is the offending code from the downvotePost method
export function downvotePost(id) {
var myHeaders = { headers: { 'Authorization': 'cakelolgarbage', 'Content-Type': 'application/json' }}
var requestBody = { 'option': 'downVote'}
var myInit = { method: 'POST',
headers: myHeaders,
body: requestBody,
mode: 'cors',
cache: 'default' }
console.log(myInit)
return (dispatch, id) => {
console.log(dispatch)
console.log(id)
dispatch(downvote(id))
return fetch(`http://localhost:3001/posts/{id}`, myInit )
.then(response => {
console.log(response)
return response.json()
})
.then(json => dispatch(receivePosts(json)))
}
}
Copy link

ghost commented Oct 26, 2017

I think line 13 should just be
return dispatch =>

Copy link

ghost commented Oct 26, 2017

if you look at export function fetchPostsIfNeeded(subreddit) in the tutorial that you pointed me to, you'll see the parameter subreddit is used within the return anon function without having to pass the parameter in. I think you similarly should be able to use id from line #1 in block 13-23 without having to pass it as a parameter

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment