I'm trying to use the fetch API from Transcrypt.
Source:
headers = {
    "Access-Control-Request-Method": "GET",
    "Access-Control-Request-Headers": "origin, x-requested-with",
    "Origin": "https://bar.com/"
}
args = {
    "method":"OPTIONS",
    "headers":headers
}
fetch("https://foo.com/",args).then(
    lambda response: print(response),
    lambda err: print(err)
)
Compiles to:
var headers = dict ({'Access-Control-Request-Method': 'GET', 'Access-Control-Request-Headers': 'origin, x-requested-with', 'Origin': 'https://bar.com/'});
        var args = dict ({'method': 'OPTIONS', 'headers': headers});
        fetch ('https://foo.com/', args).then ((function __lambda__ (response) {
            return print (response);
        }), (function __lambda__ (err) {
            return print (err);
        }));
Prints:
TypeError: Failed to execute 'fetch' on 'Window': Iterator is not an object.
If I remove the dicts from the compiled code, it runs.
How can I compile to proper Javascript object instead of dict?
 
                        
Got it now.
It turns out that:
https://www.transcrypt.org/docs/html/special_facilities.html#create-bare-javascript-objects-and-iterate-over-their-attributes-from-python-pragma-jsiter-and-pragma-nojsiter
So the code should be: