Probably this is a very stupid question, i'm new in vue.js and javascript, so please forgive me if the question is not properly explained or the answer is simple... I have a problem I wanted to get the id from one select, and put that id into the other api and display the models in the next select, the listings work beautifully as I do the rigid. But I don't know how to pass/paste the id into the async mounted axios function "api/sd/model/get", id)"
This is my template
<main class="home-page">
<select v-model="selectedMark">
<option v-for="model in items" :key="model.id">{{ model.name.value }}</option>
</select><br><br>
<select v-model="selectedModel">
<option v-for="make in info" :key="make.id" >{{ make.name.value }}</option>
</select><br><br>
<button type="submit" class="conectButton">Połącz</button>
<div class="titleCarMain"><p class="titleCar">{{selectedMark}}</p><p class="titleComponent">{{selectedModel}}</p></div>
</main>
And this is script
import axios from 'axios';
export default {
name: "App",
data() {
return {
info: null,
items: [],
selectedMark: null,
selectedModel: null,
};
},
async mounted() {
axios
.get("http://local/api/sd/make/get")
.then(response => { this.items = response.data.data.items });
const id = { id: this.selectedMark } //dont work
await axios
.post("http://local/api/sd/model/get", id) //dont work
.then(response => { this.info = response.data.data.items });
},
};
Any good soul who can help this newbie? (if can explain the why of the solution as well, for understand, will be amazing!!)
Thanks in advance!!