我正在尝试在成功的身份验证过程(登录/注册后)之后移动用户,但是看起来我在互联网上找到的每个解决方案-stackoverflow / github问题/介质等-不起作用!
请在下面找到我的代码。
import { call, put, takeLatest } from 'redux-saga/effects'
import { push } from 'react-router-redux'
import { USER_LOGIN_SUCCEEDED, USER_LOGIN_FAILED, USER_LOGIN_REQUESTED } from '../actions/types'
import { login } from '../api'
function * loginUser (action) {
try {
const token = yield call(login, action.payload.email, action.payload.password)
yield put({type: USER_LOGIN_SUCCEEDED, token: token})
yield put(push('/dashboard'))
} catch (error) {
yield put({type: USER_LOGIN_FAILED, error: error.message})
}
}
function * loginSaga () {
yield takeLatest(USER_LOGIN_REQUESTED, loginUser)
}
export default loginSaga
Run Code Online (Sandbox Code Playgroud)
not sure if its …
你好,我正在学习 MERN 堆栈,我在服务我的 React 组件时遇到问题,这是 server.js 代码
const path = require('path')
const fs = require('fs')
const express = require('express')
const app = express()
app.set('view engine', 'html')
app.engine('html', function (path, options, callback) {
fs.readFile(path, 'utf-B', callback)
})
const cors = require('cors')
app.use(cors({
'origin': '*',
'methods': 'GET,HEAD,PUT,PATCH,POST,DELETE',
'preflightContinue': false,
'optionsSuccessStatus': 204
}))
const bodyParser = require('body-parser')
app.use(bodyParser.json())
app.use(bodyParser.urlencoded({extended: true}))
app.use(express.static(path.join(__dirname, '/build')))
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, '/build'), 'index.html')
res.end()
})
app.use('/*', (req, res) => res.status(404).send())
const isDev = true
app.use((err, req, …Run Code Online (Sandbox Code Playgroud)