javascriptoboe.js

Bad value error in Oboe.js


Originally asked by Sashkan on the Oboe.js Github issues:

I'm getting a stremedResponse from a distant API. When I make an ajax call, I get the following response :

{"company_id":"3e1f975601f59090decc8f2d5ced72010162e481","airplane_type_id":"c10143316664f220a5cb87950b3dbac8794e2b15","legs":
[{"lfi_from":"FR49348","lfi_to":"FR24863","nb_pax":"1","datetime_from":"2015-12-10 15:45:00","datetime_to":"2015-12-10 16:44:00","duration":"00:59","availability":true}]},{"company_id":"3e1f975601f59090decc8f2d5ced72010162e481","airplane_type_id":"opfr8976xwqs54321zdickv678654xckvjfdf025","legs":
[{"lfi_from":"FR49348","lfi_to":"FR24863","nb_pax":"1","datetime_from":"2015-12-10 15:45:00","datetime_to":"2015-12-10 16:45:00","duration":"01:00","availability":true}]},{"company_id":"3e1f975601f59090decc8f2d5ced72010162e48e","airplane_type_id":"2368c24e9980e4eb9ccd986f32df884e5bd58707","legs":
[{"lfi_from":"FR49348","lfi_to":"FR24863","nb_pax":"1","datetime_from":"2015-12-10 15:45:00","datetime_to":"2015-12-10 16:50:00","duration":"01:05","availability":true}]}

But when I use oboe, only the first one is displayed, and immediately after, I get the following oboe error:

thrown: Error: Bad value Ln: 1 Col: 65 Chr: , at Error (native) at emitError (http://openjetfrontclean/app_dev.php/bundles/main_oboe-browser_9.js:636:20) at handleData (http://openjetfrontclean/app_dev.php/bundles/main_oboe-browser_9.js:816:20) at applyEach (http://openjetfrontclean/app_dev.php/bundles/main_oboe-browser_9.js:497:20) at emit (http://openjetfrontclean/app_dev.php/bundles/main_oboe-browser_9.js:2042:10) at XMLHttpRequest.handleProgress (http://openjetfrontclean/app_dev.php/bundles/main_oboe-browser_9.js:1253:10)
    message: "Bad value↵Ln: 1↵Col: 65↵Chr: ,"
    stack: (...)
    get stack: ()
    set stack: ()
    __proto__: DefineError.bh

Any idea why ?


Solution

  • Answer provided by JuanCaicedo

    I think that response is invalid json, which you can verify by plugging it in to http://jsonlint.com/. It looks like it's three comma-separated objects. I think it's meant to be an array? If so, just add a [ at the start of the first object and a ] at the end of the last object.

    Oboe is able to pick items out of a top-level array. Call .node('[*]', function(){...}).