设置授权标头的正确方法?钛

时间:2014-07-05 00:02:00

标签: titanium-mobile titanium-alloy

这是请求和回复:

Request

Header: AUTHORIZATION:WayXwJYTTTJaYfv2

Response

200 (OK)
Content-Type: application/json
{
    "status": "OK"
}

我的api电话:

exports.APIDeleteRequest = function(url, callback, errorCallback) {
    Ti.API.info('Delete Request is called');
    var req = Titanium.Network.createHTTPClient({
        onload : callback,
        onerror : errorCallback,
        timeout : 60000
    });

    req.open("DELETE", url);
    req.setRequestHeader('Header: AUTHORIZATION', Alloy.Globals.authToken);
    req.send();
};

我不确定在这种情况下我设置Request标头的方式是否正确。有人可以证实,谢谢。

1 个答案:

答案 0 :(得分:1)

应该是:

req.open("DELETE", url);
req.setRequestHeader('AUTHORIZATION', Alloy.Globals.authToken);
req.send();