Skip to content
Advertisement

TypeError: Incorrect type for the ‘headers’ field on ‘RequestInitializerDict’: the provided value is not of type ‘variant’

I’m new to JavaScript and I’m trying make a Github API Gateway for IFTTT(cause it can’t modify header) with JS on Cloudflare Worker. Here’s the code:

JavaScript

And I got this error when I tried to run it:

JavaScript

This is an older version which run well but with less flexibility:

JavaScript

The only difference seems to be apiRequest, but I don’t know how to fix it. I tried to claim the variable with var apiRequest = new Object() first but didn’t work.

Advertisement

Answer

Fix with this:

JavaScript

And the apiRequest will look like this:

JavaScript

This seems like what RequestInitializerDict want.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement