Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I have a problem. I'm using props to update my basketCount but I have a problem:

How can I update my basketCount ? Can you give me some advice please ?

These are my codes:

Home.vue

<template>
            <ProductList :basketCount="basketCount" :itemList="itemList" />
</template>
<script>
export default {
  data() {
     return {
        basketCount:0
created() {
        this.$axios.get(`http://localhost:3000/baskets?userId=${this.getUser.id}`).then(get_response => {
            this.basketCount = get_response.data.length || 0

I'm skipping ProductList part and I'm showing you my addToBasket function in ProductListItem.vue

addToBasket(item) {
        this.$axios.post("http://localhost:3000/baskets", item).then(basket_response => 
            console.log(basket_response);
            this.basketCount++
                provide/inject is an overkill for direct parent-child link. v-model is universally used for that
– Estus Flask
                Sep 28, 2022 at 22:23
        

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.