Using my BackEnd API, a string is returned to me. For example, the response
is :
test.sh has been executed by Java,test.sh has been executed by Java,test.sh has been executed by Java
I am looking to split this string at ","
and display each item separately. The desired output should be:
1. test.sh has been executed by Java
2. test.sh has been executed by Java
3. test.sh has been executed by Java
Currently, the string appears as follows:
1. test.sh has been executed by Java,test.sh has been executed by Java,test.sh has been executed by Java
Here is the frontend code I have implemented:
<template>
<v-form>
<v-container>
<v-card
class="mt-15 pa-4 mx-auto"
max-width="700"
color="#BDBDBD"
text = "red darken-1"
>
<ol>
<li class="white--text" v-for="item in output" :key="item">{{item}}</li>
</ol>
</v-card>
</v-container>
</v-form>
</template>
<script>
export default {
data: () => ({
items: [],
search: null,
key: '',
output: [],
}),
methods: {
async displayTerminalLog() {
let apiUrl = 'http://localhost:8091/api/v1/output/'
let response = await this.axios.get(apiUrl);
console.log(response.data.toString())
for (var text in response.data.toString().split(",")){
this.output.push(response.data[text].slice(0,
response.data.toString().length-1))}
}
}
}
</script>