Router

postBinary(path, file, onProgress, onLoad, onError, params)

Post a binary file object to the backend

Parameters

post(path, parameters)⇒ Promise.<Response>

Post data to specified backend endpoint

Parameters

put(path, parameters)⇒ Promise.<Response>

Put data to specified backend endpoint

Parameters

get(path, parameters)⇒ Promise.<Response>

Get data from specified backend endpoint

Parameters

Example

import {api} from 'writer'

api.router.get('/api/binary/url/' + uuid)
    .then((url) => {
        // Handle url
    })
    .catch((error) => {
        console.error(error);
    });

head(path, parameters)⇒ Promise.<Response>

Fetch specified backend endpoint using a http HEAD request. This is silent and will not produce any error messages.

Parameters

Example

import {api} from 'writer'

api.router.head('/api/binary/url/' + uuid)
    .then((url) => {
        // Handle url
    })
    .catch((error) => {
        console.error(error);
    });

del(path, parameters)⇒ Promise.<Response>

Make a DELETE call to a specified backend endpoint

Parameters

getConceptItem(id, imType)⇒ *

Fetch a ConceptItem from the backend

Parameters

getNewsItem(id, imType)⇒ *

Fetch a NewsItem from the backend

Parameters

updateConceptItem(uuid, concept)⇒

Updates a Concept Item

Returns: A promise with no data

Parameters

createConceptItem(concept)⇒ * | Promise.<TResult>

Creates a Concept Item

Returns: * | Promise.<TResult> - containing the resulting UUID

Parameters

checkForOKStatus(response)⇒ *

Method checks for a status code between 200 and 299 Throws error if otherwise.

Use for example when you want to reject a fetch promise

Parameters

Example

router.authorizedFetch(...)
    .then(response => checkForOKStatus(response))
    .then(response => toJson(response))
    .then(json => ...)
    .catch(error => ...)

toJson()

Deprecated

Use native response.json() instead

authorizedFetch(url, params)⇒ Promise.<*>

Parameters