How to call bitquery API in App Script

Hi there!

Attached you can find and example of how to do a simple App Script request from App Script:


    function GET_TOKEN_TEST(token) {
      const query = `
      query{
      bitcoin{
        blocks{
          count
        }
       }
    }
    `;
    const url = "https://graphql.bitquery.io/";
    const opts = {
        method: "POST",
        headers: {
            "Content-Type": "application/json",
            "X-API-KEY": "Copy there your API key"
        },
        payload: JSON.stringify({
            query
        })
    };
    var response = UrlFetchApp.fetch(url, opts)
    var w = JSON.parse(response.getContentText());
    console.log(w)
    }

Enjoy!