ApiBuilder.ApiResponse is not a constructor error @ claudia-api-builder v3.0.x
identityclash opened this issue · comments
Jerome A. C. Ngo commented
Using "claudia-api-builder": "^3.0.1"
:
The snippet below is supposed to return an error 400, but instead is throwing an internal server error.
const ApiBuilder = require('claudia-api-builder');
const api = new ApiBuilder();
api.get('/error', function () {
return new ApiBuilder.ApiResponse({ message: 'Failed validation!' }, {'Content-Type': 'application/json'}, 400);
});
-
Expected behaviour:
API returns an error 400 along with the error message. -
What actually happens:
HTTP status code is 500.
{
"errorMessage": "ApiBuilder.ApiResponse is not a constructor"
}
Gojko Adzic commented
The static ApiBuilder constructor became available in 4.1.0, so you’ll have to upgrade if you want to use that syntax. Otherwise, use return new api.ApiResponse....