Webanizr Logo
Open / sluit menu
Module sendToAPI

Last change: January 15, 2020

Current version: 1.3.1

The sendToAPI module can be used to send the received data as json body to the given url.

syntax

webanizr.send('sendToAPI', data, parameters, callback, error);

parameters

The sendToAPI module accepts the following parameters:

url__api (required)

The url of the static source or simple API. The URL should return valid JSON data.

type__caching (optional)

This parameter only accepts one value: "inmodule". If this value is present, the json is cached and the url will no longer be used to retreive the data. The cache is cleared when reloading the page.

If this parameter is omitted no caching is applied.

method__http (optional)

The method to use: GET, PUT, POST or DELETE. If the parameter is not set, POST is assumed.

send__token (optional)

If set to true, the module looks for a meta tag with the name "webanizr-token" in the head. The value of this tag will be send as security token to the API.

token__security (optional)

The security token to send to the API.

callback

This callback function is called when the data is retrieved. The function gets the retreived data as parameter. If the retreival of the data results in an error the callback function is not called, and instead the error callback is called.

error

Only available for version 1.3.2 and upwards, combined with version 1.16.0 and upwards of webanizr.js.

This callback function is called when the return code of the request was not equal to 200. 

changelog:

  • January 16, 2020 - 1.3.2 - error callback functionality added. Only works on webanizr version 1.16.0 and higher.
  • January 15, 2020 - 1.3.1 - updated dependency on authentication to 1.0.2 + reorganized code
  • September 17, 2019 - 1.2.0 - added caching and the security token