HTTP response headers?

I’m trying to create a script to upload an image of handwritten notes to the Azure Computer Vision API. When you make the API call the response has no body; the response header contains a URL that you are supposed to use to access the resulting OCR data.

I’m brand new to any kind of JavaScript… is there a way in Scriptable to access the response header? It seems like load and loadString are only dealing with the body of the response…

Wouldn’t you use

var req = new XMLHttpRequest();

That’s how you parse headers I. JavaScript. But you have to it at the point your expecting azure to send you the headers, you can’t do it after the fact.

If AJAX is involve things are, iirc, slightly different.

(I know nothing about scriptable, so this is just a JavaScript answer)

Perhaps @simonbs could comment on what the properties/functions Request.load() returns. If I output to the console the regsult of Request.load I get “[Object ScriptableKit.DataBridge]”. However I don’t see where DataBridge is documented. If its the same thing as “Data” in the documentation then it doesn’t provide access to header info.

That’s as far as I’ve gotten as well. @simonbs I’d love to know if there’s a way to get the response headers, or if that’s something that could be added in a future version!

@stevehahn Sorry for not getting back to you. Getting the response from a request will be possible in version 1.1.0 of Scriptable. The request will have a response property that is populated when the request have finished.


@simonbs Excellent, thanks a lot!