Open jrdn91 opened 6 years ago
I was able to get past this error by doing this ...
let PrintHandler = new printHandler();
jsonApi.define({
resource: "print",
handlers: PrintHandler,
...
However now I'm getting a general 500 error, I added a search and find since it was complaining about it and I'm attempting to use the search I am getting a generic 500 error, the detail just says ??
I made sure to specify the search params and added them as a query param in postman
Here is my search function
PrintHandler.prototype.search = function (request, callback) {
const self = this
console.log(request.route.query)
return callback(null, {
message: 'hello world'
}, 1)
}
Can you show me the full code for your custom handler so I can test it locally?
One of the issues you have with your search
method is that it needs to return an Array. I'm working on a PR which will make this explicit rather than failing with the generic error. Anyway try to change it to return an array with a single element and you should be able to progress.
PrintHandler.prototype.search = function (request, callback) {
const self = this
console.log(request.route.query)
return callback(null, [{
message: 'hello world'
}])
}
I'm getting this output in postman
{
"jsonapi": {
"version": "1.0"
},
"meta": {},
"links": {
"self": "/api/v1/print"
},
"data": [],
"included": []
}
Try running the server with DEBUG
environment variable set to *
(e.g. in bash: DEBUG=* npm start
). That should provide you debugging output which will make clearer what the problem is.
I see it's complaining about there not being an id
property set.
Is there a way I can specify a route handler through express and break out of these jsonapi requirements for just this one route since it's such a specific usage? I tried grabbing the express server and attaching a route handler after doing the readdirSync
but it doesn't seem to be doing anything
var app = jsonApi.getExpressServer();
app.get('/test',function(req,res){
res.send({
message: 'hello world'
})
});
Maybe this isn't possible?
I'm trying to make a custom handler that will handle my resource for making a PDF, but I keep getting a 503 in my response
I'm only implementing
POST
here because that's all I'll be usingRight now I'm just trying to get it working. Why am I getting this error? If I switch to using a real handler like the
mongodb
on it works, but just not with a custom handler