forwardemail / forwardemail/supertest

Type Error: res.status is not a function supertest

Open
#596 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
14.4k
Forks
782
PR merge metrics
No merged PRs in 30d

Description

`TypeError: res.status is not a function

49 | })
50 | .catch(error => {
> 51 | return res.status(400).json({
| ^
52 | success: false,
53 | error,
54 | results: null

at status (Routes/Controllers/auth/index.js:51:18)`

`router.post('/signup', (req, res) => {`
`let validate = ajv.compile(signupSchema);`
`let valid = validate(req.body);`
` if (!valid) {`
`return res.status(400).json({`
`success: false,`
`error: sumErrors(validate.errors),`
`results: null`
`});`
`}`
`auth`
` .signup(req.body)`
`.then(results => {`
`console.log(res.json);`
`return res.status(200).json({`
`success: true,`
`error: null,`
`results`
`});`
`})`
`.catch(error => {`
`return res.status(400).json({`
`success: false,`
`error,`
`results: null`
`});`
`});`
`});`

Link to the project [online-judge](https://github.com/NBNARADHYA/online-judge)

When testing, with supertest this problem seems to exist.

But the same code works perfectly fine when I start the server manually using npm start and when requests are sent using postman.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.