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