{"size": 1431, "ext": "js", "max_stars_repo_path": "anilist/getAnilistData.js", "max_stars_repo_name": "Road6943/Otome-Isekai-Recommendations", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "anilist/getAnilistData.js", "max_issues_repo_name": "Road6943/Otome-Isekai-Recommendations", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "anilist/getAnilistData.js", "max_forks_repo_name": "Road6943/Otome-Isekai-Recommendations", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 29.8125, "max_line_length": 136, "alphanum_fraction": 0.5080363382}
async function getAnilistData(anilist_id) {
    // Here we define our query as a multi-line string
    // Storing it in a separate .graphql/.gql file is also possible
    const query = `
        query ($id: Int) { # Define which variables will be used in the query (id)
            Media (id: $id, type: MANGA) { # Insert our variables into the query arguments (id) (type: ANIME is hard-coded in the query)
                siteUrl
                genres
                coverImage {
                    medium
                }
                description(asHtml: true)
            }
        }
    `;

    // Define the config we'll need for our Api request
    const url = 'https://graphql.anilist.co',
        options = {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
                'Accept': 'application/json',
            },
            body: JSON.stringify({
                query: query,
                variables: {
                    id: anilist_id
                }
            })
        };

    function handleResponse(response) {
        return response.json().then(function (json) {
            return response.ok ? json : Promise.reject(json);
        });
    }

    // Make the HTTP Api request
    const data = await fetch(url, options)
        .then(handleResponse)
        .catch(err => {console.error(err)});

    console.log(data)

    return data;
}
