Я хочу заполнить вызовы GET REST из приложения vuejs.
В настоящее время у меня есть следующий шаблон
<template>
<div class="app-container">
<div class="currentjob">
<h1>Current Jobs</h1>
<table>
<tr>
<th>ID</th>
<th>Status</th>
<th>AlgorithmID</th>
<th>Result</th>
</tr>
<tr v-for="job in jobs">
<td>{{ job.id }}</td>
<td>{{ job.status }}</td>
<td>{{ job.algorithmId }}</td>
<td>{{ getResult(job.id) }}</td>
</tr>
</table>
</div>
</div>
</template>
<script>
export default
{
name: 'CurrentJobs',
data()
{
return {
jobs: null
}
},
mounted()
{
this.$axios
.get(this.$baseUrl + 'job')
.then(response => (this.jobs = response.data))
},
methods:
{
getResult: function(jobid)
{
this.$axios.get(this.$baseUrl + 'job/result/'+jobid).
then(response =>
{
return response.data // does not work
})
}
}
}
</script>
Обычно я могу выполнить запрос GET следующим образом
this.$axios.
get(this.$baseUrl + 'job/result/'+jobid).
then(response =>
{
// return response.data // does not work
}
)
Но я не могу добавить оператор возврата вфункция стрелки внутри метода then
.Как я могу вернуть ответ на вызов REST?Какую основную концепцию мне не хватает?