I am using a dynamic method for all my XHR requests, because I always need to send constant data, like user_type
:
var app = new Framework7({
…
methods: {
backendFactory: function (apiMethod, method, params) {
var app = this;return new Promise((resolve, reject) => { app.request(app.utils.extend( { url: url, method: method, data: { user_type: 0, }, success(data) { resolve(data); }, error(err) { reject(err); }, }, (params || {}) )) }); },
}
});
The call that I am using looks like:
app.methods.backendFactory(‘commerce-category/1/’, ‘GET’).then(function (data) {
console.log(data);
}).catch(function (err) {
console.log(err);
});
It works fine when I use POST method, but when I use GET method, no data is sent. I have seen that it doesn’t happen when I use app.request.get()
, which sends the data like in POST method. Is there a way to make it works with app.request()
?