mozilla / ping-centre

INACTIVE - http://mzl.la/ghe-archive
Mozilla Public License 2.0
8 stars 10 forks source link

Create a Promise inside of send ping and reject on parse failure #11

Closed jaredlockhart closed 8 years ago

jaredlockhart commented 8 years ago

https://github.com/mozilla/ping-centre/blob/master/ping-centre.js#L33

Here we pass the data into the validator and pass a callback in to handle the validation error case however this does not block the calling scope from moving immediately on to fetch so this will not prevent us from fetching with invalid data. We need to create a Promise and then either reject or resolve on it and then in the then case move on to fetch and resolve the outer promise using the success or failure of the fetch promise.

jaredlockhart commented 8 years ago

Something like this:

https://gist.github.com/jaredkerim/fbffe2a0dce129db362e7feb3224f9e3