如何将api函数中的数据绑定到vue.js中的数据对象

时间:2018-12-03 07:56:01

标签: api vue.js axios

我正在对天气API执行SELECT 'Dropping_Percentage', ( Cast(dropped_count AS DECIMAL(16, 9)) / Cast(new_count AS DECIMAL(16, 9 )) ) * 100 FROM (SELECT count AS New_count, '1' a FROM new_count)a, (SELECT Count(*) Dropped_count, '1' b FROM pfo_bhi_new N RIGHT JOIN pfo_bhi_old o ON o.id_membid_claimid_c = N.id_membid_claimid_c WHERE N.id_membid_claimid_c IS NULL)c WHERE a.a = c.b ,因此我想过滤有关“当前天气”等信息的特定数据。

Axios.get()

请检查我在“数据”中的“ stringSummary”部分。这不行吗?

感谢您的帮助。

1 个答案:

答案 0 :(得分:1)

您应在weatherData块中分配then

methods: {
  async weatherApi() {
    axios.get('https://api.darksky.net/forecast/
    89cef1a2abe989e0d09a4ebd75f02452/53.551085,-9.993682? 
    lang=de&units=si')
    .then((response) => {
      this.weatherData = {
        stringSummary: response.data.currently.summary
      }
      return response;
  })
  .catch((error) => {
    console.log(error);
  });
},