-
Notifications
You must be signed in to change notification settings - Fork 0
/
defaults.js
34 lines (27 loc) · 887 Bytes
/
defaults.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
export function defaultJqueryBuildSendRequestArguments(options) {
let url = this._getUrl(options);
let data = options.attrs;
if (data) {
data = JSON.stringify(data);
}
let { headers, method } = options;
//let headers = Object.assign({}, this.headers, options.headers);
let ajaxOptions = { method, data, headers, processData: false, };
return [url, ajaxOptions];
}
const backboneDummyModel = {
trigger() { }
}
var backboneMethodUnMap = {
'POST' : 'create',
'PUT': 'update',
'PATCH': 'patch',
'DELETE': 'delete',
'GET': 'read'
};
export function defaultBackboneBuildSendRequestArguments(options) {
options.shouldTriggerRequest = false;
let model = options.entity || backboneDummyModel
let method = backboneMethodUnMap[options.method];
return [method, model, options];
}