Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

aman5440's avatar

Vue Data not updating

Here is the script. But its not getting update on Axios response. Please help me out. No error no clue am getting nothing.

<template>

<section class="wrapperMain">
    Manage Product
    {{product_titles}}
	</section>
</template>
<script>
import { onMounted, ref } from 'vue';

const ManageProduct = {
    setup(){
        let product_titles = ref([])
        onMounted(()=>{
            axios.get(`/search/product_titles/all`).then(data=>{
                product_titles = data.data.data.map(item=> {return {"code":item.id, "label":item.title}})
                console.log("that.product_titles",product_titles);
            });
        })

        return{
            product_titles,
        }
    },

}
export default ManageProduct;
</script>
0 likes
1 reply
wingly's avatar

When using ref you should update the value property of the reactive object so basically product_titles.value = to your value

Please or to participate in this conversation.