diff options
| author | mo khan <mo@mokhan.ca> | 2017-01-14 10:24:22 -0700 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2017-01-14 10:24:22 -0700 |
| commit | 1ed254f893e6679a0fa38470844f7a3ad5f0eb67 (patch) | |
| tree | d9479082a825dfe912c310f1c7f9af128ae98ec2 | |
| parent | e293475484509fd40aa3fe6087d9e62545a79523 (diff) | |
inline success.
| -rw-r--r-- | app/infrastructure/api.js | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/app/infrastructure/api.js b/app/infrastructure/api.js index 40f02ae..da8e8a5 100644 --- a/app/infrastructure/api.js +++ b/app/infrastructure/api.js @@ -14,17 +14,20 @@ export default class Api { post(relativeUrl, body, success) { const url = this.buildUrlFor(relativeUrl); - const jsonBody = JSON.stringify(body); this.defaultHeaders((headers) => { console.log(`POST ${url}`); - this.execute(url, { method: "POST", headers: headers, body: jsonBody }, success); + this.execute(url, { + method: "POST", + headers: headers, + body: JSON.stringify(body) + }, success); }); } execute(url, options, success) { fetch(url, options) .then((response) => response.json()) - .then((json) => success(json)) + .then(success) .catch((error) => console.error(error)) .done(); } |
