J
J
JenerIIC2021-10-12 15:45:12
typescript
JenerIIC, 2021-10-12 15:45:12

How to write the received value to a variable for output, Vue?

Good afternoon. Tell me why the data.count value is not assigned to text112 and is not displayed accordingly? I get the data.count value, but the assignment does not work.

// Отделльный файл с классом APIData
export default class APIData {
    static async getData(url: string) {
        return await fetch(url)
                .then(result => result.json())
                .catch(error => console.log(error));
    }
}

//Файл компонента Vue
<template>
    ...
   <p>{{ text112 }}</p>
    ...
</template>

<script lang="ts">
import APIData from '../APIData';
import {Component, Vue} from 'vue-property-decorator';

@Component
export default class InvHistory extends Vue {
    titlesHistory = [
        { text: 'Название', value: 'processDefinitionName'},
        { text: 'Запустил', value: 'startUserId'},
        { text: 'Сервер', value: 'hostName'},
        { text: 'Версия', value: 'version'},
        { text: 'Время начала', value: 'startTime'},
        { text: 'Длительность, м', value: 'durationInMillis'}
    ];

    historyCountUrl: string = 'https://bpmn-engine/count';

    text112 = 0;

    hist = APIData.getData(this.historyCountUrl)
            .then(data => this.text112 = data.count); // Присваиваем значение счетчика в переменную text112
  
}
</script>

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question