javascript - Questions about the mock interface of react and dva
欧阳克
欧阳克 2017-07-05 10:52:30
0
2
895

I made a registration page using dva, using the fake interface of roadhogrc. The server can receive the POST request, but it can’t get req.body. What should I do? I’m so anxious. What should I do? It’s been a whole morning, can anyone help me aaaa...QAQ...
github link

[`POST /api/signin`](req,res){
        const user = req.body;
        console.log(user) //undefined
        res.json('123')
    }
欧阳克
欧阳克

温故而知新,可以为师矣。 博客:www.ouyangke.com

reply all(2)
过去多啦不再A梦

I have been troubled by this problem for many days. Today I saw your question and the comments on the first floor and it suddenly clicked... The roadhog version that dva scaffolding relies on by default is 0.5.... Just update the roadhog version, npm i roadhog@0.6.0-beta.3 Remember to change the dependencies, I just tested it myself and it was successful

给我你的怀抱

Have a cursory look at roadhog’s documentation. It says:

Since we are referring to express, let’s think it is express

Looking at the dependency, there is body.parser, so req.body should be available.

I tried the link you sent and it works. . . = =


Check the front end

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template