Skip to content

Instantly share code, notes, and snippets.

@Westixy
Last active April 20, 2018 09:51
Show Gist options
  • Save Westixy/44d5982b4f81b1a05b27ab1c0842b453 to your computer and use it in GitHub Desktop.
Save Westixy/44d5982b4f81b1a05b27ab1c0842b453 to your computer and use it in GitHub Desktop.
class LogSharer {
constructor(project, api = 'http://172.17.102.83/api/projects/') {
this.config = { project, api }
}
get url() {
return this.config.api + this.config.project
}
sendData(data) {
let fd = new FormData()
fd.append('data',JSON.stringify(data))
fetch(this.url, {
method: 'POST',
body: fd,
})
.then(_ => {})
.catch(e => console.error('failed to send data', data, e))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment