matthew-andrews / isomorphic-fetch

Isomorphic WHATWG Fetch API, for Node & Browserify
MIT License
6.95k stars 289 forks source link

req.body has set body as property #127

Open renehauck opened 7 years ago

renehauck commented 7 years ago

Hi,

i send a post with

fetch(url, {
            method: 'POST',
            mode: 'no-cors',
            redirect: 'follow',
            body: JSON.stringify({ hello:"world" }),
            headers: new Headers({
                'Content-Type': 'application/x-www-form-urlencoded',
                Accept: 'application/json',
            })
        })

to my (express) server:

 this.express.post(Routes.Login, (req, res, next) => {
            let request = req.body;
            console.log(request)
            res.sendStatus(200);

and console.log show this result

{ '{"hello":"world"}': '' }

the stringified object { hello:"world" } is a property of req.body.

Is this a bug, or what I am doing wrong?

Thx

matthew-andrews commented 7 years ago

It's been a while since I used express but what you've described doesn't seem unexpected to me. What did you expect to happen in this case?