Kindly help me by letting know, how can I pass headers, like Authorization etc., while calling a REST Endpoint from oj.Collection API
https://learncodeshare.net/2017/03/29/making-a-rest-call-from-oracle-jet/
I tried "customURL" from the above link, but could not get the headers
It isn't explicitly mentioned in the docs, but you can add headers as one of the object input properties while calling the collection.fetch()
method.
For e.g.:
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);
}
});
};