Rest
@nuclia/core • Docs
@nuclia/core / Rest
Class: Rest
Handles the elementary REST requests to the Nuclia backend, setting the appropriate HTTP headers.
Its main methods implement the corresponding HTTP verbs (GET is get(), POST is post(), etc.)
For each of them, extraHeaders is an optional parameter that can be used to add headers to the request.
On POST, PUT, PATCH and DELETE, the synchronous parameter will make the call synchronous,
meaning the response will be returned only when the operation is fully completed. It is false by default.
The default headers set by Nuclia.rest are:
'content-type': 'application/json'AuthorizationorX-NUCLIA-SERVICEACCOUNTdepending on the type of authentication.
The default headers will be overridden by extraHeaders if they have the same entries.
doNotParse is a boolean that can be used to disable the automatic JSON parsing of the response.
Implements
Constructors
new Rest()
new Rest(
nuclia):Rest
Parameters
• nuclia: INuclia
Returns
Defined in
libs/sdk-core/src/lib/rest/rest.ts:33
Methods
checkAuthorization()
checkAuthorization(
endpoint):Observable<object>
Check if the user has access to the given endpoint, and return the corresponding roles.
Parameters
• endpoint: string
Returns
Observable<object>
allowed
allowed:
boolean
roles
roles: (
NucliaDBRole|KBRoles)[]
Implementation of
Defined in
libs/sdk-core/src/lib/rest/rest.ts:228
delete()
delete<
T>(path,extraHeaders?,synchronous?,zoneSlug?):Observable<T>
Type Parameters
• T
Parameters
• path: string
• extraHeaders?
• synchronous?: boolean
• zoneSlug?: string
Returns
Observable<T>
Implementation of
Defined in
libs/sdk-core/src/lib/rest/rest.ts:82
get()
get<
T>(path,extraHeaders?,doNotParse?,zoneSlug?):Observable<T>
Type Parameters
• T
Parameters
• path: string
• extraHeaders?
• doNotParse?: boolean