Home  >  Q&A  >  body text

javascript - Questions about the mock interface of react and dva

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')
    }
欧阳克欧阳克2663 days ago864

reply all(2)I'll reply

  • 过去多啦不再A梦

    过去多啦不再A梦2017-07-05 10:54:30

    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

    reply
    0
  • 给我你的怀抱

    给我你的怀抱2017-07-05 10:54:30

    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

    reply
    0
  • Cancelreply