Namespace: net

apogee.net

This namespace includes network request functions.

Methods

(static) callbackRequest(url, onSuccess, onError, options)

This method does a standard callback request. It includes the following options:

  • "method" - HTTP method, default value is "GET"
  • "body" - HTTP body for the request
  • "header" - HTTP headers, example: {"Content-Type":"text/plain","other-header":"xxx"}
Parameters:
Name Type Description
url String

This is the url to be requested

onSuccess function

This is a callback that will be called if the request succeeds. It should take a String request body argument.

onError function

This is the callback that will be called it the request fails. It should take a String error message argument.

options Object

These are options for the request.

(static) jsonRequest(url, options) → {Promise}

This method returns a promise object for an HTTP request. The promist object
returns the JSON body of the URL if it resolves successfully.

Parameters:
Name Type Description
url String

This is the url to be requested

options Object

These are options for the request. See apogee.net.callbackRequest for the options definition.

Returns:

This method returns a promise object with the URL body as text.

Type
Promise

(static) textRequest(url, options) → {Promise}

This method returns a promise object for an HTTP request. The promist object
returns the text body of the URL if it resolves successfully.

Parameters:
Name Type Description
url String

This is the url to be requested

options Object

These are options for the request. See apogee.net.callbackRequest for the options definition.

Returns:

This method returns a promise object with the URL body as text.

Type
Promise