Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise((resolve: Resolver, reject: Rejecter) => {
const xhr = new XhrIo();
xhr.listenOnce(EventType.COMPLETE, () => {
try {
switch (xhr.getLastErrorCode()) {
case ErrorCode.NO_ERROR:
const json = xhr.getResponseJson() as Resp;
log.debug(LOG_TAG, 'XHR received:', JSON.stringify(json));
resolve(json);
break;
case ErrorCode.TIMEOUT:
log.debug(LOG_TAG, 'RPC "' + rpcName + '" timed out');
reject(
new FirestoreError(Code.DEADLINE_EXCEEDED, 'Request time out')
);
break;
case ErrorCode.HTTP_ERROR:
const status = xhr.getStatus();
log.debug(