FirebaseArrayIndexError interface

复合类型,其中包含FirebaseError对象和可用于获取错误项目的索引。

签名:

export interface FirebaseArrayIndexError 

特性

财产类型描述
错误Firebase错误错误对象。
指数数字原始数组中错误项目的索引作为所调用的 API 方法的一部分传递。

FirebaseArrayIndexError.error

错误对象。

签名:

error: FirebaseError;

FirebaseArrayIndexError.index

原始数组中错误项目的索引作为所调用的 API 方法的一部分传递。

签名:

index: number;

例子

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);
  });