question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

v9: Cleanup http interface

See original GitHub issue

I run into SyntaxError: Unexpected token < in JSON at position 0

It seems that it may be caused by the same issue as #384 - where http error page was parsed as json.

I want to check is it actually happening but right now I have no idea how to get response code of a failing fetch.

// SyntaxError: Unexpected token < in JSON at position 0
wtf.fetch('https://wiki.openstreetmap.org/wiki/Tag:highway%3Dmotorway').then((doc) => {
    //console.log(doc.sentences(0).text())
    //console.log(doc.infobox())
    //console.log(doc.infobox().json())
})

// works
wtf.fetch('Poland').then((doc) => {
  console.log(doc.sentences(0).text())
  console.log(doc.infobox())
  console.log(doc.infobox().json())
})

/*
// from readme sample
// fails to parse infobox
wtf.fetch('https://muppet.fandom.com/wiki/Miss_Piggy').then((doc) => {
    console.log(doc.sentences(0).text())
    console.log(doc.infobox())
    if(doc.infobox() != undefined) {
        console.log(doc.infobox().json())
    }
})

*/

Issue Analytics

  • State:open
  • Created 3 years ago
  • Comments:16 (13 by maintainers)

github_iconTop GitHub Comments

2reactions
wvanderpcommented, Dec 28, 2020

I was already looking at this for a bit but christmas got in the way. I already wrote out my usual wall of text and will post it tomorrow.

1reaction
spencermountaincommented, Dec 28, 2020

in addition to allowing users to set custom headers, per @Vacilando , we should set this as a default header - https://www.mediawiki.org/wiki/API:Etiquette#Request_limit recommends to set Accept-Encoding: gzip

Read more comments on GitHub >

github_iconTop Results From Across the Web

Apache Tomcat 9 Configuration Reference (9.0.70)
Introduction. The HTTP Connector element represents a Connector component that supports the HTTP/1.1 protocol. It enables Catalina to function ...
Read more >
Fix list for IBM WebSphere Application Server traditional V9
IBM HTTP Server, Fix List, Detailed list of APARs for IBM HTTP Server ... PH37897, Application edition management feature fails to clean up...
Read more >
Scheduled System Jobs v9 - Postgres Enterprise Manager
Server log table cleanup, This job runs periodically to purge old data from the server log table. Every twelve hours, daily starting from...
Read more >
TKU Corruption after 9x to 10x Upgrade - Discussion - BMC ...
With "Auto Cleanup" activated, I try to delete the old TKU (v9) but ... the support document "Configuring pattern cleanup" [http://discovery.bmc.com/ ...
Read more >
Documentation/v9 - Genesys Documentation
... Mode and control it from a custom agent desktop by using an HTTP REST API, ... This release also includes scripts to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found