111 |
Sheets:
112 | {sheetList.map((item) => (
113 |
{item.qData?.title}
114 | ))}
115 |
116 | );
117 | };
118 |
119 | export default SheetList;
120 | ```
121 |
122 | More examples can be found in the [examples](examples.md) section.
123 |
124 | ◁ [Back to overview](../README.md)
125 |
--------------------------------------------------------------------------------
/docs/rest.md:
--------------------------------------------------------------------------------
1 | # REST
2 |
3 | ◁ [Back to overview](../README.md)
4 |
5 | Each rest entity is exposed as it's own javascript module. It contains all api calls and types exposed by the entity service. They can be imported from `@qlik/api` as a sub module of the package like `/spaces` in the example below. These modules both has named exports and a default export. Types are always named exports.
6 |
7 | ```ts
8 | import spaces, { type Spaces } from "@qlik/api/spaces";
9 | await { data: mySpaces } = await spaces.getSpaces();
10 |
11 | // mySpaces now has the type Spaces
12 | ```
13 |
14 | Each module can also be imported directly from `@qlik/api`.
15 |
16 | ```ts
17 | import { spaces, users } from "@qlik/api";
18 | ```
19 |
20 | These modules are the default exports from each respective sub module. The types from the sub modules are not exposed here since they would introduce name conflicts. The types need to be imported from the respective sub modules.
21 |
22 | Info about these entities and their api's can be found [here](https://qlik.dev/apis/#rest).
23 |
24 | ## HTTP Calls
25 |
26 | The http calls uses the native fetch api. Each http call with a response status in the 200 range will resolve to an object with structure `{ status, headers, data }`. If status is in the >=300 range an error will be thrown.
27 |
28 | ```ts
29 | import { getSpaces } from "@qlik/api/spaces";
30 |
31 | try {
32 | const { status, headers, data: spaces } = await getSpaces();
33 | // status < 300
34 | if (spaces.data) {
35 | // the spaces list is returned as "data"
36 | // There are spaces
37 | }
38 | } catch (e) {
39 | // status >= 300
40 | // something went wrong
41 | }
42 | ```
43 |
44 | ## Error handling
45 |
46 | Every http response that has a status over 300 is considered to be an error and the promise is rejected. To handle this in typescript you can do the following:
47 |
48 | ```ts
49 | import { deleteExtension, type DeleteExtensionHttpError } from "@qlik/qmfe/extensions";
50 |
51 | try {
52 | const { status } = await deleteExtension("