AJAX response error: net::ERR_EMPTY_RESPONSE

The response you’re getting is actually correct. Per the docs, Firebase returns a 200 status code and an empty responsenet::ERR_EMPTY_RESPONSE is exactly that. What you should do is check for both null and a 200 status code in the response; if true, you can safely assume that the post was deleted.

My personal opinion is that Firebase should really consider returning something more substantial than nothing and a generic, catch-all status code. I’d prefer something like 204 No Content, or 410 Gone. But, alas.

Side note: this conditional will never return anything if the post doesn’t belong to the author — your API should still return something (an error, probably in this case) even if your conditional doesn’t match. Like:

if (firebase.auth().currentUser.uid.toString() == author) { 
    // your code
} else {
    res.status(401).send("User does not have permission to complete the operation.")
}

Leave a Comment