Skip to content

Instantly share code, notes, and snippets.

@zalazhar
Last active May 24, 2017 18:10
Show Gist options
  • Save zalazhar/e58bc0aefc9ce15fa9cbbbb9f78b0aa6 to your computer and use it in GitHub Desktop.
Save zalazhar/e58bc0aefc9ce15fa9cbbbb9f78b0aa6 to your computer and use it in GitHub Desktop.
function form (json){
return Object.keys(json).map(key=>encodeURIComponent(key)+'='+encodeURIComponent(json[key])).join('&');
};
function createRobject(Rlib, Rfunc, Rparams) {
return fetch(Rlib + Rfunc, {
method: 'post',
headers: {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/x-www-form-urlencoded'
},
body: form((Rparams))
})
};
function loadRobject(Location , type) {
return fetch(Location).then (function (response){ return response.text()});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment