Home > Back-end >  firebase RTDB startAfter() is not a function
firebase RTDB startAfter() is not a function

Time:10-02

I am trying to paginate a list of items with Vuefire, and for some reason I am getting an error with the below code (when I call startAfter(), the function works fine with startAt())

lastVisible is an object in my component's state with the property expire_date (a UNIX timestamp)

This is the error I get

Any idea what is wrong?

    async seeFurtherGames() {
      var games_ref = db.ref('games')
      console.log("GameBrowser.seeOlderGames()", this.lastVisible, games_ref)
      if (this.lastVisible) {
        var start = this.lastVisible.expire_date
        var query = games_ref.orderByChild('expire_date').startAfter(start).limitToFirst(this.item_limit)
        await this.$bind("games", query)
        this.setLastVisible()
        
      }
    }
Uncaught (in promise) TypeError: games_ref.orderByChild(...).startAfter is not a function
    at _callee3$ (webpack-internal:///./node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/views/GameBrowser.vue?vue&type=script&lang=js&:257)
    at f (chrome-extension://bfnaelmomeimhlpmgjnjophhpkkoljpa/content_script/inpage.js:141)
    at Generator._invoke (chrome-extension://bfnaelmomeimhlpmgjnjophhpkkoljpa/content_script/inpage.js:141)
    at Generator.next (chrome-extension://bfnaelmomeimhlpmgjnjophhpkkoljpa/content_script/inpage.js:141)
    at asyncGeneratorStep (webpack-internal:///./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:9)
    at _next (webpack-internal:///./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:31)
    at eval (webpack-internal:///./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:38)
    at new Promise (<anonymous>)
    at eval (webpack-internal:///./node_modules/@babel/runtime/helpers/esm/asyncToGenerator.js:27)
    at VueComponent.seeFurtherGames (webpack-internal:///./node_modules/cache-loader/dist/cjs.js?!./node_modules/babel-loader/lib/index.js!./node_modules/cache-loader/dist/cjs.js?!./node_modules/vue-loader/lib/index.js?!./src/views/GameBrowser.vue?vue&type=script&lang=js&:270)

CodePudding user response:

The startAfter and endBefore operations in the Firebase Realtime Database were introduced in version 8.2.7 of the JavaScript SDK.

CodePudding user response:

I was able to fix this problem by upgrading firebase from v8 to v9

  • Related