In my action file I create a fetchMethod
export const requestEmbedToken = () => (dispatch) => {
return axios.get('http://localhost:7071/api/getTokens')
.then(response => {
console.log("token embed", response)
})
}
app.js
import { requestEmbedToken } from './redux/actions'
function App(token, requestToken) {
const [embedToken, setEmbedToken] = useState(token.token);
useEffect(() => {
if (token.token === undefined) {
requestToken()
setEmbedToken(token.token)
}
});
return (
const mapDispatchToProps = (dispatch) => {
return ({
requestToken: () => dispatch(requestEmbedToken())
})
}
export default connect(mapStateToProps, mapDispatchToProps)(App)
Actually I'm getting an error
TypeError: requestToken is not a function