FirebaseArrayIndexError interface

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

签名

export interface FirebaseArrayIndexError 

属性

属性 类型 说明
错误 FirebaseError 错误对象。
索引 数字 作为调用的 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);
 
});