FirebaseArrayIndexError interface

Composite type which includes both a FirebaseError object and an index which can be used to get the errored item.

Signature:

export interface FirebaseArrayIndexError 

Properties

Property Type Description
error FirebaseError The error object.
index number The index of the errored item within the original array passed as part of the called API method.

FirebaseArrayIndexError.error

The error object.

Signature:

error: FirebaseError;

FirebaseArrayIndexError.index

The index of the errored item within the original array passed as part of the called API method.

Signature:

index: number;

Example

var registrationTokens = [token1, token2, token3];
admin.messaging().subscribeToTopic(registrationTokens, 'topic-name')
  .then(function(response) {
    if (response.failureCount > 0) {
      console.log("Following devices unsucessfully subscribed to topic:");
      response.errors.forEach(function(error) {
        var invalidToken = registrationTokens[error.index];
        console.log(invalidToken, error.error);
      });
    } else {
      console.log("All devices successfully subscribed to topic:", response);
    }
  })
  .catch(function(error) {
    console.log("Error subscribing to topic:", error);
  });