Red Reaper
Red Reaper

Reputation: 31

Google App Scripts ReferenceError: URLSearchParams is not defined

I am trying to access an API in an apps scripts function. I have tested my code in VS code and it works just fine, but when I run it in apps scripts, I get an error saying "ReferenceError: URLSearchParams is not defined". Does anyone know of a fix? None of the similar questions offer a viable solution.

Code:

async function ApiTest() {
let status = "watching";
let num_watched_episodes = 10;
let token = "MyTokenIsHere";
let id = 50346;
const urlParams = new URLSearchParams({
  status: status,
  num_watched_episodes: num_watched_episodes,
});

fetch('https://api.myanimelist.net/v2/anime/' + id + '/my_list_status', {
    method: "PATCH",
    headers: {
        'Authorization': 'Bearer ' + token,
    },
    body: urlParams,
})
}

Upvotes: 0

Views: 1125

Answers (0)

Related Questions