複合類型,其中包含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);
});