Q
Q
qwentry2022-03-09 09:44:11
Vue.js
qwentry, 2022-03-09 09:44:11

How to send year and get real time data?

Good afternoon.
The page has a select field with a year selection.
How to add a year to an axios request so that when the year changes, the received information is also updated?

<script>
import axios from 'axios'

export default {
    data () {
        return {
            year: 2022,
            error: '',
            form: [],
        }
    }

    mounted: function() {
        axios
                .get("http://example/" + this.year)
                .then(response => {
                    this.form= response.data;
                })
                .catch(function(e){
                    this.error = e;
                });
    },

}
</script>


More or less like this? or wrong

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Anton, 2022-03-09
@Fragster

https://v3.ru.vuejs.org/ru/guide/computed.html#%D0...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question