views:

23

answers:

1

I need to retrieve a JSON resource which requires HTTP Basic authentication. Therefore, I need to set a request header for a DataSource.IO object.

I see that the IO utility itself supports a header key in its configuration object. However, since I'm new to YUI, I can't figure out how to set this configuration value through the mediation of DataSource.

To be clear, I don't need help constructing a correct Authorization header, just getting YUI to send the headers I construct. Thanks much.

+1  A: 

You can set IO config values via DataSource.IO's ioConfig config object (http://developer.yahoo.com/yui/3/api/DataSource.IO.html#config_ioConfig):

var ds = new Y.DataSource.IO({
    source: "script.php",
    ioConfig: {
        method: "POST",
        data: "foo=bar",
        timeout: 1000
    }
});
Jenny Donnelly
Thank you. I saw that documentation, but I guess I was in a dazed stupor or something and didn't understand it.
David M.