R
R
Richard Millie2019-10-04 14:11:23
JavaScript
Richard Millie, 2019-10-04 14:11:23

How to correctly pass an api method?

There is such a method
/api/metrics/{data-source-id}
for example
/api/metrics/3c0d507e-ca58-11e9-9ccf-98ded00049dd
answer

{
    "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

Please help me pass it correctly to this section of code (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);
          })
      }
    }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Richard Millie, 2019-10-04
@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);
})
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question