Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion rest-api/typescript-sdk/react-rest-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Open in [Codesandbox](https://githubbox.com/thoughtspot/developer-examples/tree/
- Links to the Thoughtspot developer docs for the features used in this example.
- [Rest Api Reference](https://developers.thoughtspot.com/docs/rest-apiv2-reference)
- [Rest Api Sdk](https://developers.thoughtspot.com/docs/rest-api-sdk)
- [Developer Examples]((https://github.com/thoughtspot/developer-examples))

## File structure
.
Expand Down Expand Up @@ -38,7 +39,7 @@ $ npm run dev
### Run token server

```
$ npm run start-token-server
$ npm run token-server
```

### Technology labels
Expand Down
8 changes: 4 additions & 4 deletions rest-api/typescript-sdk/react-rest-api/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion rest-api/typescript-sdk/react-rest-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"start": "npm run token-server & vite"
},
"dependencies": {
"@thoughtspot/rest-api-sdk": "^2.12.1",
"@thoughtspot/rest-api-sdk": "^2.17.1",
"express": "^4.21.2",
"react": "^19.0.0",
"react-dom": "^19.0.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,28 @@
import { ThoughtSpotRestApi, createBearerAuthenticationConfig } from "@thoughtspot/rest-api-sdk";
import {
ThoughtSpotRestApi,
createBearerAuthenticationConfig,
} from "@thoughtspot/rest-api-sdk";
import { THOUGHTSPOT_HOST } from "../constants";
import { getCachedAuthToken } from "../get-auth-token";

/**
* This will create a bearer authenticated client to connect to thoughtspot server
*
*
* @returns ThoughtSpotRestApi
*/
let thoughtSpotClient: ThoughtSpotRestApi;
export const getThoughtSpotClient = () => {
if (!thoughtSpotClient) {
const bearerConfig = createBearerAuthenticationConfig(THOUGHTSPOT_HOST, getCachedAuthToken);
const bearerConfig = createBearerAuthenticationConfig(
THOUGHTSPOT_HOST,
getCachedAuthToken,
{
additionalHeaders: {
"Accept-Language": "en-US",
},
}
);
thoughtSpotClient = new ThoughtSpotRestApi(bearerConfig);
}
return thoughtSpotClient;
}
};
Loading