solr-node
solr-node copied to clipboard
does not work with query wt !== json
for a query like *:*&wt=csv&rows=0
it throws an error
FetchError: invalid json response body at http://localhost:8983/solr/gettingstarted/select?*:*&rows=0&wt=csv reason: Unexpected token T in JSON at position 0 at node_modules/node-fetch/lib/body.js:48:31 at process._tickDomainCallback (internal/process/next_tick.js:135:7)
i think it is because of lines 106 and 164 in client.js where it always try to interpret response as json return res.json();
even if sometimes it should be return res.text();
The following code snippet gives me this error
;(async () => {
const result = await client.search('q=*:*')
console.log('Response:', JSON.stringify(result.response))
})()
(node:16591) UnhandledPromiseRejectionWarning: FetchError: invalid json response body at http://localhost:8983/solr/coll
ection1/select?q=*:* reason: Unexpected token < in JSON at position 0
at /home/thevirajshelke/solr-node-code/node_modules/node-fetch/lib/index.js:272:32
at process._tickCallback (internal/process/next_tick.js:68:7)
And the following works fine
;(async () => {
const result = await client.search('q=*:*&wt=json')
console.log('Response:', JSON.stringify(result.response))
})()
So your code expects JSON response always. we need to make lines 106 and 164 in client.js where it always try to interpret the response as JSON return res.json();
as conditional.