httpplease.js icon indicating copy to clipboard operation
httpplease.js copied to clipboard

get request doesn't work

Open zwhitchcox opened this issue 8 years ago • 3 comments

This code

  1 require('httpplease')({ method: 'GET',
  2   url: 'https://thingspace.io/get/dweets/for/no_thing',
  3   headers: {}
  4 },function(err,response) {
  5   console.log('text: ',response)
  6 })

just logs

text:  Response {
  request:
   Request {
     method: 'GET',
     url: 'https://thingspace.io/get/dweets/for/no_thing',
     headers: {},
     timeout: 0,
     errorOn404: true,
     onload: undefined,
     onerror: undefined,
     xhr:
      { UNSENT: 0,
        OPENED: 1,
        HEADERS_RECEIVED: 2,
        LOADING: 3,
        DONE: 4,
        readyState: 1,
        onreadystatechange: null,
        responseText: '',
        responseXML: '',
        status: 0,
        statusText: null,
        withCredentials: false,
        open: [Function],
        setDisableHeaderCheck: [Function],
        setRequestHeader: [Function],
        getResponseHeader: [Function],
        getAllResponseHeaders: [Function],
        getRequestHeader: [Function],
        send: [Function],
        handleError: [Function],
        abort: [Function],
        addEventListener: [Function],
        removeEventListener: [Function],
        dispatchEvent: [Function],
        onload: null,
        onerror: null,
        onabort: null,
        ontimeout: null,
        onprogress: null } },
  xhr:
   { UNSENT: 0,
     OPENED: 1,
     HEADERS_RECEIVED: 2,
     LOADING: 3,
     DONE: 4,
     readyState: 1,
     onreadystatechange: null,
     responseText: '',
     responseXML: '',
     status: 0,
     statusText: null,
     withCredentials: false,
     open: [Function],
     setDisableHeaderCheck: [Function],
     setRequestHeader: [Function],
     getResponseHeader: [Function],
     getAllResponseHeaders: [Function],
     getRequestHeader: [Function],
     send: [Function],
     handleError: [Function],
     abort: [Function],
     addEventListener: [Function],
     removeEventListener: [Function],
     dispatchEvent: [Function],
     onload: null,
     onerror: null,
     onabort: null,
     ontimeout: null,
     onprogress: null },
  headers: {},
  status: 0,
  text: '',
  body: '',
  contentType: null,
  isHttpError: false }

It has a status of 0, no text, and not body. However, when I enter the url into my browser, I get the expected result. There is nothing in the documentation about what to do with the response object, so I might be doing something wrong there.

zwhitchcox avatar May 10 '16 17:05 zwhitchcox

Did you try logging the error?

matthewwithanm avatar May 27 '16 08:05 matthewwithanm

This is probably a duplicate of #23

such avatar Aug 25 '16 11:08 such

This dose not cut the standards anymore, xhr isn't streamable, and don't exist in web worker IE is also dead and unsupported soon in agust by MS themself.

How about deprecating this package, archive the repo and suggest for alternatives? this haven't been updated in years

jimmywarting avatar May 22 '21 16:05 jimmywarting