-
Notifications
You must be signed in to change notification settings - Fork 759
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
expressjs - res.status is not a function TypeError #416
Comments
I encountered the same error when applying supertest on a express route. const routes = express.Router();
routes.get('/', ()=> res.status(200).send('blub'))
request(routes).get('/').end() // status not a function
request(app.use(routes)).get('/').end() // works |
Same issue. The solution of @nikhedonia brings it to work |
Hi @rimiti , would you mind giving a working example that adapts @nikhedonia 's PoC above? Additionally, can you explain why arrow functions are not supported in this context? Since arrow function are now (at time of writing) the default way to declare functions in node (the function keyword is being phased out of most example code and books), can you please explain the design considerations of not having supertest work with arrow functions in this particular example? I understand you're quite busy and appreciate the help 😄 |
Having the same issue even with function() {} |
Fixed, in my case..
From documentation: https://expressjs.com/ru/api.html
|
he tendido el mismo problema y lo que pasa es que tienes definida la request del get con req y el de la funcion request tambien esto deveria funcionar: |
I also have the same problem. router.post('/signin',(req,res,next)=>{
const username=req.body.username;
const password=req.body.password;
// check vaild input
if(!username||!password){
return res.status(422).json({err:"Please add all the fields."})
}
User.findOne({userId:username})
.then(saveduser=>{
console.log(saveduser)
if(saveduser){
const hash=saveduser.password;
bcrypt.compare(password,hash,(err,res)=>{
if(err)
console.log(err);
if(res)
return res.status(422).json({error:"This line is causing error!"})
else res.json({err:"Email/password do not match!"})
})
}
.catch(err=>{
console.log(err);
})
}) ErrorTypeError: res.status is not a function Can, somebody explain me why i am getting this error. |
@ats1999 You are using |
@mathurin59000 Thankyou, I was doing same mistake |
@iLyxa3D Thanks |
I faced the issue in production |
Thank you so much ! The solution as well as your explanation helped! |
Always use (err, req, res, next) in sequence else you would also get this res.status error. |
code with the error of res.status is not a function TypeError
clean code work well
i don't know where is the error lol |
export const getPosts =async(res , req , next) => { console.log(PostMessage); res.status(200).json(postMessage); I got the error : res.status() is not a function . |
Request is the first parameter, Response the second and Next the third. Invert req and res in your parameters. |
import React from 'react'; const store = configureStore(reducers, compose(applyMiddleware(thunk))) ; ReactDOM.render( Error is : "reducer" is a required argument, and must be a function or an object of functions that can be passed to combineReducers |
Instead of passing directly reducers, pass an object like this, {reducer: reducers} (reducers which is your combineReducers) |
Thanku @mathurin59000 |
ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17 //Why did this error come even after my website run ..? |
Do classes consume any memory in java ..? if yes tell me a reason. |
@mathurin59000 Do classes consume any memory in java? if yes tell me a reason. |
TypeError: response.status is not a function I got this error please help me to solve this issus |
Hello,
I used supertest with tape, sinon, proxyquire & expressJS, I got this error :
this is my route function
my unit test
Do you have any idea?
The text was updated successfully, but these errors were encountered: