Closed sefeng211 closed 9 months ago
cc @fergald It is mainly for easier type safety to make the API shape look like this.
If we made them the same class then we would have to specify that certain methods (like setUrl
or setData
) will raise exceptions when called on the wrong kind. Making them different classes avoids that and for typescript coders, it becomes a compile-time error to call setUrl
of a POST beacon.
The API is now repurposed as fetchLater()
which supports both HTTP methods. https://github.com/whatwg/fetch/pull/1647
Have we considered to shape the API as
PendingBeacon("Get", ...)
andPendingBeacon("Post", ...)
? This would match what thefetch
andXHR
do. It seems uncommon with the current setup.