-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Hello! Your Http error classes can't work properly in Node.js express 5.2.1 version.
in my api.js:
const express = require('express')
const app = express()
app.use(express.json())
const authentification = express.Router()
authentification.post('/signin', basicAuth, async (request, response) => {
return await crud.signin(request, response)
})
//...
in my crud.js:
const status = require('./status')
async function signin(request, response){
try{
const jwtCredentials = await auth.jwtAuth.recordCredentials(request)
}
catch (error) {
status.token_not_provided()
}
return response(201).json(jwtCredentials)
}
in my status.js:
const { HttpError } = require('http-json-errors')
module.exports = {
token_not_provided: (detail=null) => new HttpError(
401, {
message: 'Token wasn\'t provided',
detail: detail
}
),
}
I get correct error code but http response isn't jsonable, it is a plain html text.
Metadata
Metadata
Assignees
Labels
No labels