simple xhr utility.
no event supported.
no binary supported.
Install with component(1):
$ component install chemzqm/got
-
url
is the url to request -
optional
option
could contains:method
get, post, delete, head,get
by defaultquery
query string or query object serialized byencodeURIComponent
body
request body send to the server side, by default encoded byencodeURIComponent
type
request body type, could bejson
andform
,form
by defaultheaders
headers to be senttimeout
request timeout in millisecond,10s
by default
-
callback function takes two arguments
err
is error object could benetwork error
,crossDomain error
ortimeout error
.res
is the response object hasres.text
for plain response text,res.status
for status code,res.body
for parsed response body if response content type is json,res.ok
is true ifstatus==2xx
MIT