-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunc.js
More file actions
32 lines (27 loc) · 742 Bytes
/
func.js
File metadata and controls
32 lines (27 loc) · 742 Bytes
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
import { Async } from '../../Async.js';
/** GET request */
function getRequest ($http, url) {
return Async.Promise(
(resolve, reject) => $http.get(url).then( payload => {
"use strict";
console.log('GET payload =', payload);
return resolve(payload.data);
}).catch(reject)
);
}
/** POST request */
function postRequest ($http, url, data) {
return Async.Promise(
(resolve, reject) => $http.post(url, JSON.stringify(data)).then( payload => {
"use strict";
console.log('POST payload =', payload);
return resolve(payload.data);
}).catch(reject)
);
}
// Exports
const request = $http => ({
get: (...args) => getRequest($http, ...args),
post: (...args) => postRequest($http, ...args),
});
export default request;