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