The following works perfectly well for me:
app.get('/doi/meta/:doiName1/:doiName2', function(request, response) {
var path = '/doi/json?doi='+request.params.doiName1+'/'+request.params.doiName2;
// etc.
For instance, I can call:
curl -X GET http://localhost:1337/doi/meta/09.1010/9347426
and get the response I am expecting. (Note the name of the object I am querying has a slash.)
Because there is some potential variability in the object names, I have a need to alter the server so that I can structure my queries like this:
curl -X GET http://localhost:1337/doi/meta?doiName=09.1010/9347426
I have tried numerous approaches, but I invariably receive the following response:
[SyntaxError: Unexpected end of input]
which suggests to me that I am looking for the problem in the wrong place. However, I can change the server code back to the above and it works fine. My code currently looks like this:
app.get('/doi/meta', function(request, response) {
//var path = '/doi/json?doi='+request.params.doiName1+'/'+request.params.doiName2;
var args = url.parse(request.url, true).query;
var path = 'doi/json?doi='+args['doiName'];
console.log('path is '+path);
// etc.
The console.log statement is never reached. What is the issue that is causing this Unexpected End of Input error?
A SyntaxError: Unexpected end of input error typically means either you are missing a closing parenthesis, brace, bracket, or similar character somewhere in your code or you are trying to JSON.parse() a string that is missing such characters.
Run your code/JSON string through a javascript linter (e.g. jshint) to find syntax errors.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With