|
|
|
@ -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 |
|
|
|
|