Fix cmd and add json to http

This commit is contained in:
Michal Szczepanski 2020-07-03 22:48:58 +02:00
parent ea37422ea0
commit d90ed53f08
3 changed files with 7 additions and 4 deletions

@ -17,6 +17,6 @@
"parcel-bundler": "^1.12.4"
},
"dependencies": {
"@szczepano/huh": "0.0.6"
"@szczepano/huh": "0.0.7"
}
}

7
huh.js

@ -64,7 +64,10 @@ export const HTTP = (o) => {
if (o.type) {
req.setRequestHeader('Content-type', o.type);
}
if(o.json) {
req.setRequestHeader('Content-type', 'application/json');
o.data = JSON.stringify(o.data);
}
console.log(o.url);
req.send(o.data);
return new Promise((success, failure) => {
@ -124,7 +127,7 @@ class CmdWrapper {
this.once = once;
this.chain = chain;
this.handler = (e) => {
this.cmd();
this.cmd(e);
if(this.once) {
delete _hlisteners[e.type];
removeEventListener(e.type, this.handler);

@ -1,6 +1,6 @@
{
"name": "@szczepano/huh",
"version": "0.0.6",
"version": "0.0.7",
"description": "huh",
"main": "huh.js",
"license": "BSD-3-Clause",