Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getCharacter(id, callback) {
- var query = `
- query($id: Int) {
- Character (id: $id) {
- id
- image {
- large
- }
- name {
- first
- last
- }
- }
- }
- `;
- var variables = {
- id: id
- };
- var url = 'https://graphql.anilist.co',
- options = {
- method: 'POST',
- headers: {
- 'Content-Type': 'application/json',
- 'Accept': 'application/json',
- },
- body: JSON.stringify({
- query: query,
- variables: variables
- })
- };
- fetch(url, options).then(handleResponse)
- .then(function(response) {
- callback(response.data.Character);
- })
- .catch(function(err) {
- handleError(err)
- callback(null);
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement