Query From a Client
Last updated
Last updated
There are several ways to query our GraphQL API :
You can use any GraphQL client. Here is an example with Apollo Client:
import { ApolloClient, InMemoryCache, gql } from '@apollo/client';
const client = new ApolloClient({
uri: 'https://api.sismo.io',
cache: new InMemoryCache(),
});
const query = gql`
query {
mintedBadges {
balance
tokenId
badge {
name
}
}
}`
const result = await client.query({ query });
const query = `
query {
mintedBadges {
level
badge {
tokenId
}
badge {
name
}
}
}`
const res = await fetch('https://api.sismo.io', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Accept': 'application/json',
},
body: JSON.stringify({ query})
});
const { data, errors } = await res.json();