From fd1ce4d741cc5992cc5d3d6109dc46cddf871ec2 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 4 Jun 2018 14:21:46 -0700 Subject: Begin adding unconfigured notifier --- app/scripts/lib/bug-notifier.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 app/scripts/lib/bug-notifier.js (limited to 'app/scripts/lib/bug-notifier.js') diff --git a/app/scripts/lib/bug-notifier.js b/app/scripts/lib/bug-notifier.js new file mode 100644 index 000000000..d6a2ed2c9 --- /dev/null +++ b/app/scripts/lib/bug-notifier.js @@ -0,0 +1,24 @@ +class BugNotifier { + notify (uri, message) { + return postData(uri, message) + .then(data => console.log(data)) // JSON from `response.json()` call + .catch(error => console.error(error)) + } +} + +function postData(uri, data) { + + return fetch(url, { + body: JSON.stringify(data), // must match 'Content-Type' header + credentials: 'same-origin', // include, same-origin, *omit + headers: { + 'content-type': 'application/json' + }, + method: 'POST', // *GET, POST, PUT, DELETE, etc. + mode: 'cors', // no-cors, cors, *same-origin + }) + .then(response => response.json()) // parses response to JSON +} + +module.exports = BugNotifier + -- cgit v1.2.3 From d07c664b2c31469d84dd3c84a929b8d4ba552e8c Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 4 Jun 2018 14:30:24 -0700 Subject: Fine tune error posting --- app/scripts/lib/bug-notifier.js | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'app/scripts/lib/bug-notifier.js') diff --git a/app/scripts/lib/bug-notifier.js b/app/scripts/lib/bug-notifier.js index d6a2ed2c9..42f943485 100644 --- a/app/scripts/lib/bug-notifier.js +++ b/app/scripts/lib/bug-notifier.js @@ -1,14 +1,11 @@ class BugNotifier { notify (uri, message) { return postData(uri, message) - .then(data => console.log(data)) // JSON from `response.json()` call - .catch(error => console.error(error)) } } function postData(uri, data) { - - return fetch(url, { + return fetch(uri, { body: JSON.stringify(data), // must match 'Content-Type' header credentials: 'same-origin', // include, same-origin, *omit headers: { @@ -17,7 +14,6 @@ function postData(uri, data) { method: 'POST', // *GET, POST, PUT, DELETE, etc. mode: 'cors', // no-cors, cors, *same-origin }) - .then(response => response.json()) // parses response to JSON } module.exports = BugNotifier -- cgit v1.2.3 From 3bfc40c2848d3e814fca663fa039c261097976c3 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 4 Jun 2018 14:59:46 -0700 Subject: Add version to report --- app/scripts/lib/bug-notifier.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'app/scripts/lib/bug-notifier.js') diff --git a/app/scripts/lib/bug-notifier.js b/app/scripts/lib/bug-notifier.js index 42f943485..bfb3e9770 100644 --- a/app/scripts/lib/bug-notifier.js +++ b/app/scripts/lib/bug-notifier.js @@ -16,5 +16,7 @@ function postData(uri, data) { }) } -module.exports = BugNotifier +const notifier = new BugNotifier() + +module.exports = notifier -- cgit v1.2.3 From 22754e3e1f496b2dde140eea56a88bc7237fda42 Mon Sep 17 00:00:00 2001 From: Dan Finlay Date: Mon, 4 Jun 2018 15:10:51 -0700 Subject: Linted --- app/scripts/lib/bug-notifier.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'app/scripts/lib/bug-notifier.js') diff --git a/app/scripts/lib/bug-notifier.js b/app/scripts/lib/bug-notifier.js index bfb3e9770..4d305b894 100644 --- a/app/scripts/lib/bug-notifier.js +++ b/app/scripts/lib/bug-notifier.js @@ -9,7 +9,7 @@ function postData(uri, data) { body: JSON.stringify(data), // must match 'Content-Type' header credentials: 'same-origin', // include, same-origin, *omit headers: { - 'content-type': 'application/json' + 'content-type': 'application/json', }, method: 'POST', // *GET, POST, PUT, DELETE, etc. mode: 'cors', // no-cors, cors, *same-origin -- cgit v1.2.3