Back to Top

rq master

simplify async requests

rq()

simplify asynchronous requests

Returns

Void

rq.get(url)

execute a get-request

Parameters

Name Type Description
url String

the url of the request

Examples

rq.get("YOUR_URL").then(handleData).catch(handleError);

Returns

Void

rq.post(url, data)

execute a post-request

Parameters

Name Type Description
url String

the url of the request

data Object

the data to be sent in the body

Examples

rq.post("YOUR_URL", yourData).then(handleResponse).catch(handleError);

Returns

Void

rq.put(url, data)

execute a put-request

Parameters

Name Type Description
url String

the url of the request

data Object

the data to be sent in the body

Examples

rq.put("YOUR_URL", yourData).then(handleResponse).catch(handleError);

Returns

Void

rq.delete(url)

execute a delete-request

Parameters

Name Type Description
url String

the url of the request

Examples

rq.delete("YOUR_URL").then(handleResponse).catch(handleError);

Returns

Void

rq.fetch(url, options)

execute a fetch

Parameters

Name Type Description
url String

the url of the request

options Object

the options object

Examples

// define options
var options = {
 method: "POST",
 headers: new Headers({
     "Content-Type": "application/json"
 }),
 body: JSON.stringify(data) 
}
rq.fetch("YOUR_URL", options).then(handleResponse).catch(handleError);

Returns

Void

handleResponse(response)

handle the response

Parameters

Name Type Description
response type

the full response object

Returns

type

the parsed response

handleJSONResponse(response)

handle the json response

Parameters

Name Type Description
response type

the full json response object

Returns

type

the parsed json response

handleTextResponse(response)

handle the xml response

Parameters

Name Type Description
response type

the full xml response object

Returns

type

the parsed xml response