I have thunk properly imported and installed in my index.js file. I am trying to set up an action that will render a loading page while it does a fetch, and then a second fetch inside a .then() block. This is because each fetch needs to retrieve data from a rails show page and then use that code to create a JS object and add it to an array. The code is as follows...
return (dispatch) => {
dispatch({type: 'LOAD_FIGURE'})
let movesLen = moves.length // Going to be either 2 or 3
if (movesLen == 2){
fetch(`http://localhost:3000/moves/show/${moves[0]}`) // Generate first move
.then(resp => resp.json())
.then(json => console.log(json)) // make this functional later
.then(fetch(`http://localhost:3000/moves/show/${moves[1]}`) // Generate the second move
.then(resp => resp.json())
.then(json => console.log(json)) // make this functional later
)
}
}
This will just return with the following error
Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
Uncaught (in promise) SyntaxError: Unexpected token < in JSON at position 0
I'm unsure what could be going wrong here, as this fetch is pretty basic. I'm worried it has something to do with the nested fetch, but the fact that I get the error twice also makes me think while it fetches both, both return the same error.