oracle-jet - 从 oj.Collection 或 oj.Model 传递请求标头
问题描述
请通过告诉我如何在从 oj.Collection API 调用 REST 端点时传递标头(如授权等)来帮助我
https://learncodeshare.net/2017/03/29/making-a-rest-call-from-oracle-jet/
我从上面的链接中尝试了“customURL”,但无法获取标题
解决方案
collection.fetch()
文档中没有明确提到它,但是您可以在调用该方法时将标头添加为对象输入属性之一。
例如:
self.model = oj.Model.extend({
url: someURL,
idAttribute: 'id'
});
var myModel = new self.model();
var collection = oj.Collection.extend({
url: someURL,
model: myModel
});
self.myCollection = new collection();
return new Promise(function (resolve, reject) {
self.myCollection.fetch({
headers: headers,
success: function (collection, response, options) {
resolve(response);
}
});
};
推荐阅读
- numpy - 批量张量切片,切片 B x N x M 和 B x 1
- android - Kotlin中recyclerview项目点击事件是否需要接口?
- javascript - 防止 redux 存储值在组件中再次被使用
- javascript - 如何在多页 vue 应用程序中的页面之间传输状态?
- gradle - 为什么 Gradle 开始报告“不匹配的版本”
- html - 如何将div放在中间?
- c# - 查看模型未更新
- pandas - PandasUDF 可以接受一系列类型的字符串并返回一系列类型的数组吗?
- regex - 如何使用一个捕获组获取单独的组
- python - 如何使用 Python 中未记录的 API 或未记录的 MQTT 消息协议发送 Instagram Direct 消息?