mirror of https://github.com/status-im/fathom.git
19 lines
286 B
JavaScript
19 lines
286 B
JavaScript
|
'use strict';
|
||
|
|
||
|
var Client = {};
|
||
|
|
||
|
Client.request = function(resource, args) {
|
||
|
args = args || {};
|
||
|
args.credentials = 'include'
|
||
|
|
||
|
return fetch(`/api/${resource}`, args).then((r) => {
|
||
|
if( r.ok ) {
|
||
|
return r.json();
|
||
|
}
|
||
|
|
||
|
throw new Error(r);
|
||
|
})
|
||
|
}
|
||
|
|
||
|
export default Client
|