gpt4 book ai didi

ajax - 预先输入猎犬的自定义 header

转载 作者:行者123 更新时间:2023-12-03 17:56:35 25 4
gpt4 key购买 nike

我想在我的猎犬请求中添加一个自定义 header ,这是我的代码,但是它不起作用。

var datasource = new Bloodhound({
datumTokenizer: Bloodhound.tokenizers.whitespace,
queryTokenizer: Bloodhound.tokenizers.whitespace,
remote: {
url: url,
prepare: function (query, settings) {
var authHeaders;
settings.type = "POST";
settings.data = param + '=' + query;
settings.headers = {
'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
};


return settings;
},
wildcard: '%QUERY'
}
});

任何想法?

最佳答案

为typeahead.js v0.11.0添加自定义 header 的方法是:

var bloodhound = new Bloodhound({
datumTokenizer: function (d) {
return Bloodhound.tokenizers.whitespace(d.value);
},
queryTokenizer: Bloodhound.tokenizers.whitespace,

remote: {
url: 'https://server/api/v1/clients?auth_token=3000193534a97fc4a252ddfc966e3ef178c071e4079d35ce4b',
prepare: function (query, settings) {
settings.url = settings.url + '&q=' + query
settings.headers = {
"Authorization": "Basic " + btoa("username:password")
};

return settings;
}
},
limit: 5 });

关于ajax - 预先输入猎犬的自定义 header ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34503684/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com