Skip to content

Running apollo client example in nodejs environment gives "ReferenceError: CloseEvent is not defined" error #255

Answered by enisdenjo
sal-limones asked this question in Q&A
Discussion options

You must be logged in to vote

CloseEvent does not exist in the ws library, it is exclusively a browser global class. You can, however, check if a value is like a close event. Two properties can distinguish a close event, here's the check:

function isLikeCloseEvent(val) {
  return 'code' in Object(val) && 'reason' in Object(val);
}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@sal-limones
Comment options

Answer selected by sal-limones
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants