Skip to main content

setHeaders()

Description

Sets custom HTTP headers that RestDataProvider attaches to every request sent to the server

info

The setHeaders() method is a part of the RestDataProvider service intended for working with server.

Usage

setHeaders(headers: object): void;

Parameters

  • headers - (required) an object whose keys are header names and values are header values. The headers are appended to the default Content-Type: application/json header on every request sent via send().

Example

The most common use case is attaching an authorization token to every request:

const url = "https://some_backend_url";
const restProvider = new kanban.RestDataProvider(url);

restProvider.setHeaders({
"Remote-Token": "eyJpZCI6IjEzMzciLCJ1c2VybmFtZSI6ImJpem9uZSIsImlhdC...",
});

To set headers only for a particular request rather than for every request, pass them as the fourth argument to send() instead.

Related articles: Working with server: Multiuser backend