Request.headers ? HELP!

I’m trying to figure out how to send an http header.

I’m just stuck (I’m sure) on syntax. Please advise.

FYI: the page I’m calling just returns the headers, what I’m really trying to do is send an API key to a different URL, but I’m trying to just get the headers to work for now. Thanks!

let user = {
  user: "jon",
  key: AHDUI9JD8HKHA6E
}

let req = new Request(url)
req.headers = user
let data = await req.loadString()
QuickLook.present(data)

Shouldn’t the value of key be a string? Looks like it’s being treated as a variable since it’s not in quotes.

of course I found an example RIGHT AFTER I posted my question. Figures. :slight_smile:

req.headers = {“X-API-Key” : “the key”, “X-User” : “jon” };

1 Like