I
I
it_pear_yurec2021-02-15 00:15:17
Vue.js
it_pear_yurec, 2021-02-15 00:15:17

Why is the data not coming?

Why doesn't telegram bot receive data from computed properties filteredProducts and filteredProducts2 ??

computed: {
    ...mapGetters({
      cartProducts: 'cart/productsList',
      cartPrice: 'cart/totalPrice'
    }),
    filteredProducts() {
      return this.cartProducts.map( p => p.product.title).toString()
    },
    filteredProducts2() {
      return this.cartProducts.map( p => p.qty).toString()
    }
  },
  methods: {
    isValid() {
      let valid = true;
      if (this.fullName.length < 1) {
        this.isFullNameInvalid = true;
        valid = false;
      } else {
        this.isFullNameInvalid = false;
      }
      if (this.email.length < 10) {
        this.isEmailInvalid = true;
        valid = false;
      } else {
        this.isEmailInvalid = false;
      }
      if (this.adres.length < 3) {
        this.isAdresInvalid = true;
        valid = false;
      } else {
        this.isAdresInvalid = false;
      }
      return valid;
    },
    async onSubmit() {
      if (this.isValid()) {
        this.status = cartStatus.creating;
        const success = await this.$store.dispatch("cart/submit", {
          fullName: this.fullName,
          email: this.email,
          adres: this.adres
        });
        this.status = success ? cartStatus.success : cartStatus.fail;
        this.$axios.post(
          "https://api.telegram.org/bot1558775847:AAEB42_s9dLU73wqhz3t90kB5S40Tul2FCI/sendMessage?chat_id=1400064880&parse_mode=html&text=" +
          JSON.stringify(
            "Имя " + this.fullName + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " +
            "Телефон " + this.email + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " +
            "Адрес " + this.adres + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " 
            + "Блюда" + this.filteredProducts + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " 
            + "Количество " + this.filteredProducts2 + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " + " " 
            + "Итоговая цена заказа " + this.cartPrice
          ) 
        ).then(res => {
          this.sent = true;
          document.location.href = '/thank'
        });
      }
    }
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex, 2021-02-15
@it_pear_yurec

On the page, they can be rendered after sending or removed just before it. It doesn't say anything. Check what is in these variables directly during the onSubmit call. Check which final string is generated in your JSON.stringify. In the end, if we are talking about the browser, open the debugger and look at the body of the request being sent. This is all in order to understand at what point the data is lost.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question