A
A
Andrei6652020-05-21 20:49:25
firebase
Andrei665, 2020-05-21 20:49:25

How to convert object {__ob__: Observer}?

Good evening.
Please tell me how to solve the following problem

export default {
  data() {
    return {
      locations: [],
      posts: [],
      page: 1,
      perPage: 10,
      pages: []
    };
  },
  firestore() {
    <b>return {
      locations: db.collection("testTask")  Здесь приходят данные из БД в читаемом виде 
    };</b>
  },
  computed: {
    displayedPosts() {
      return this.paginate(this.posts);
    }
  },
  methods: {
    getPosts() {
      this.posts = [];
      this.pages = [];
      <b>const data = this.locations;   </b>  <--- здесь объект превращается в {__ob__: Observer}
      console.log(data);
      for (let i = 0; i < data.length; i++) {
        this.posts.push({
          title: data[i].title,
          id: i + 1,
          index: i
        });
      }
    },


Some data comes from the database, and if the locations are immediately substituted and sorted out in the markup, then everything works as it should.
But the data needs to be passed through methods, because there is pagination. As far as I understand, the same observer observer is attached to the object there, and then it is not possible to disassemble it into components.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question