Update the Javascript instructions for initializing Flamenco's API (#104387)
Updated to match the current way of initializing API's with `getAPIClient()` It seems possible the Python instructions might need an update as well. Reviewed-on: https://projects.blender.org/studio/flamenco/pulls/104387
This commit is contained in:
parent
74d96bd02e
commit
190e26adc0
@ -53,10 +53,10 @@ components:
|
|||||||
The JavaScript code for the web-application will look something like this:
|
The JavaScript code for the web-application will look something like this:
|
||||||
|
|
||||||
```JavaScript
|
```JavaScript
|
||||||
import { apiClient } from '@/stores/api-query-count';
|
import { getAPIClient } from '@/api-client';
|
||||||
import { MetaApi } from "@/manager-api";
|
import * as API from "@/manager-api";
|
||||||
|
|
||||||
const metaAPI = new MetaApi(apiClient);
|
const metaAPI = new API.MetaApi(getAPIClient());
|
||||||
metaAPI.getVersion()
|
metaAPI.getVersion()
|
||||||
.then((version) => {
|
.then((version) => {
|
||||||
this.flamencoName = version.name;
|
this.flamencoName = version.name;
|
||||||
@ -69,17 +69,17 @@ metaAPI.getVersion()
|
|||||||
|
|
||||||
This follows a few standard steps:
|
This follows a few standard steps:
|
||||||
|
|
||||||
1. **Import the `apiClient`**. For the web-app, this actually is a little wrapper
|
1. **Import `getAPIClient`**. For the web-app, this actually is a little wrapper
|
||||||
for the actual API client. The wrapper takes care of showing a "loading"
|
for the actual API client. The wrapper takes care of showing a "loading"
|
||||||
spinner in the top-right corner when API calls take a long time to return a
|
spinner in the top-right corner when API calls take a long time to return a
|
||||||
response.
|
response.
|
||||||
2. **Import the API class** that contains this operation. This always has the form
|
2. **Import the API class** that contains this operation. This always has the form
|
||||||
`{tag}Api`, where `{tag}` comes from the `tag: ...` in the OpenAPI YAML
|
`{tag}Api`, where `{tag}` comes from the `tag: ...` in the OpenAPI YAML
|
||||||
file. In our case, the tag is `meta`, so the code imports `MetaApi`.
|
file. In our case, the tag is `meta`, so the code imports `MetaApi`.
|
||||||
3. **Construct the API object** with `new MetaApi(apiClient)`. You only have to
|
3. **Construct the API object** with `new MetaApi(getAPIClient())`. You only have to
|
||||||
do this once; after that you can call as many functions on it as you want.
|
do this once; after that you can call as many functions on it as you want.
|
||||||
4. **Call** the function. The function name comes from the `operationId` in the YAML
|
4. **Call** the function. The function name comes from the `operationId` in the YAML
|
||||||
file,
|
file.
|
||||||
5. **Handle** the succesful return (`.then(...)`) and any errors (`.catch(...)`).
|
5. **Handle** the succesful return (`.then(...)`) and any errors (`.catch(...)`).
|
||||||
|
|
||||||
All API function calls, like the `metaAPI.getVersion()` function above,
|
All API function calls, like the `metaAPI.getVersion()` function above,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user