comewithme38
@comewithme38

Как правильно передать api метод?

Есть такой метод
/api/metrics/{data-source-id}
например
/api/metrics/3c0d507e-ca58-11e9-9ccf-98ded00049dd

ответ
{
    "success": true,
    "data": {
        "entities": {
            "all": {
                "CARDINAL": 5,
                "GPE": 4,
                "NORP": 7,
                "LOC": 3,
                "ORG": 3,
                "EMAIL": 1
            },
            "top3": {
                "NORP": 7,
                "CARDINAL": 5,
                "GPE": 4
            },
            "total": 23,
            "items": 2,
            "percentage": 27.272727272727273
        }
    }
}
"all": all entities with count
"top3": top3 entities with count
"total": total entities found
"items": total items (tables) containing entities
"percentage": % of total entities


Помогите правильно его передать в этот участок кода (vue.js) :
methods: {
			setId () {
				this.dataSecretId = this.$route.params.id;
			},
			goTo(route, id){
				if (this.$route.path === route){
					return
				}
				router.push({
					path: route,
					params: { dataSecret: id}
				})
			},
			fillData () {	
				this.ScoreDonutPercents = 79;

				this.ClassifiedHighLevelScoreValue = 37;
				this.ClassifiedHighLevelScoreMax = 99;

				this.TablesHighLevelScoreValue = 30;
				this.TablesHighLevelScoreMax = 72;

				this.AnalyticsHighLevelScoreValue1 = 50;
				this.AnalyticsHighLevelScoreValue2 = 80;
				this.AnalyticsHighLevelScoreValue3 = 18;

				this.AnalyticsMax = 3456;
				this.AnalyticsHighLevelScoreMax1 = this.AnalyticsMax;
				this.AnalyticsHighLevelScoreMax2 = this.AnalyticsMax;
				this.AnalyticsHighLevelScoreMax3 = this.AnalyticsMax;

			},
			getData () {
				let self = this;
				HttpService.methods.post(`/results/`+this.dataSecretId)
					.then(function (response) {
						console.log(response.data.data)
						// self.dataSecrets = response['data']['data'];
					})
					.catch(function (error) {
						console.log(error);
					})
			}
		}
  • Вопрос задан
  • 115 просмотров
Решения вопроса 1
comewithme38
@comewithme38 Автор вопроса
test() {
let self = this;
HttpService.methods.post('/api/metrics/'+ this.dataSecretId)
.then(response => {
console.log(response.success)
self.dataSecrets = response['data']['data'];
})
.catch(error => {
console.log(error);
})
}
Ответ написан
Комментировать
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы