TypeError: res.status is not a function
At this point:
upload = uploadpicture(finalBuffer).then((res)=>{ //success request
the res
is the result of promise uploadpicture
function (that is the parsedBody
), not the res
from the express route. So indeed, it has no status
function. Try change the then
callback name like:
upload = uploadpicture(finalBuffer).then((otherName)=>{ //success request
The accepted answer directly addresses the OP's problem, but I post another solution since you can also encounter this error in other places.
When you have:
api.use((error: ErrorRequestHandler, request: ExpressRequest, response: ExpressResponse) => { response.status(500).end() // response.status is not a function})
Because the error handling route must accept 4 arguments for express to identify it as an error middleware.
api.use((error: ErrorRequestHandler, request: ExpressRequest, response: ExpressResponse, next: NextFunction) => { response.status(500).end()})
Just adding the next function (or whatever argument you're missing) will fix it.
https://github.com/visionmedia/supertest/issues/416#issuecomment-514508137