Getting Started
What can I do with the JavaScript client?
The Bettermode JavaScript client (gql-client
) allows developers to effortlessly interact with Bettermode GraphQL API using Node.js or JavaScript on backend or frontend.
To get started, you can simply install @tribeplatform/gql-client
and use it in your JavaScript project.
npm install @tribeplatform/gql-client
Here is an example of how you can use Bettermode JS client to log basic fields of the first 5 spaces in your community:
import { TribeClient } from '@tribeplatform/gql-client'
const client = new TribeClient({
graphqlUrl: 'https://app.tribe.so/graphql',
accessToken: '{yourAccessToken}',
})
client.spaces.list({ limit: 5 }, "basic").then(spaces => {
console.log('List of 5 spaces:', spaces)
})
Alternatively, you can set the access token using setToken
method or pass it in each request as the last argument:
import { TribeClient } from '@tribeplatform/gql-client'
const client = new TribeClient({
graphqlUrl: 'https://app.tribe.so/graphql',
})
client.setToken('{yourAccessToken}')
// or
client.spaces.list({ limit: 5 }, "basic", '{yourAccessToken}').then(spaces => {
console.log('List of 5 spaces:', spaces)
})