3

How can I get response code from navigator.sendBeacon? I need to have some indicator that can say me that request is failed? Particularly, I am looking for a way to identify bad request (request that was send with “bad” malformed json and got 4xx response code). Is there any way to do it while using sendBeacon?

From documentation:

The sendBeacon() method returns true if the user agent is able to successfully queue the data for transfer, Otherwise it returns false.

So, it is not returning false if request is invalid.(and response code is 4xx)

navigator.sendBeacon(that.sushiEndpoint, sushiPayload)

davidgyoung
  • 63,876
  • 14
  • 121
  • 204
WomenWhoCode
  • 396
  • 1
  • 6
  • 18
  • I have the same question. Maybe commenting on this will bring it back to the front pages after so long without an answer. – Steven Powell Oct 08 '20 at 14:26

0 Answers0