Introduction

Weavy has a Rest API on the server to work with data. To work with the server endpoints in the client you may use weavy.ajax() to seamlessly integrate client authentication instead of setting up ajax authentication on your own.

You can use the provided server endpoints or create your own endpoints.

The server always returns data with UTC timezone, so you may have to convert any dates and times into your preferred timezone.

Using weavy.ajax()

You may use the built-in ajax for calling the JSON API endpoints on the server. You can send data along with the request or retrieve data from the server. The ajax method integrates your existing JWT authentication into your ajax calls. You may also provide any additional settings for the request and the function returns a promise.

jQuery ajax is used internally and you may override or extend any settings in the jqXHR by providing custom jQuery Ajax settings.

weavy.ajax(url, [data], [method], [settings]) ⇒ Promise

url : string URL to the JSON endpoint. May be relative to the connected server.
[data : object] Data to send. May be an object that will be encoded or a string with pre encoded data.
[method : string] HTTP Request Method Defaults to GET
[settings : jqAjaxSettings] Settings to extend or override jQuery Ajax settings.

<script>

   var weavy = new Weavy({

       jwt: "{server_generated_jwt_token}"

   });

 

   // Search for a space

   weavy.ajax("/api/search", {

       q: "My Space",

       et: "space"

   }).then(function (result) {

       console.log("Found " + result.count + " results");

   });

</script>