小编Joh*_*yen的帖子

在Vue.js中异步并等待

我在使用Promise(??)使用VueJS,axios,Async / Await从REST-API检索数据时遇到问题。我需要调用两个不同的REST-API。一个是给我一张清单,我可以遍历它,这很好。

<template>
  <div>
  <div v-if="posts && posts.length">
    <div v-for="post of posts">
       {{post.name}}        
       <img :src="getUserPicturePath(post.name)" />
      </div>
    </div>
  </div>
</template>
Run Code Online (Sandbox Code Playgroud)

如您所见,另一种方法是在v-for之间,调用使用axios的方法。

<script>
import axios from 'axios'
export default {
  data: () => {
    posts: []
  }
  created() {
  // a method to fill up the post-array
 },
   methods: {
    async getUserPicturePath(name){
      const response = await axios.get('linkToApi'+name)
      console.dir(response.data.profilePicture.path)
      return response.data.profilePicture.path
    }
  }
}
</script>
Run Code Online (Sandbox Code Playgroud)

console.dir(response.data.profilePicture.path)-部分是给正确的路径profilePicture,但<img :src="getUserPicturePath(post.name)" />在上面的<template>,写[Object Promise]

有什么建议我怎么走吗?

rest promise async-await vue.js axios

6
推荐指数
1
解决办法
4551
查看次数

检索潜在客户广告Facebook API

我在检索潜在客户广告时遇到问题。

我有广告ID和页面ID。我还没有创建它们,但是被添加为开发人员。

我正在尝试使用PHP SDK和此https://developers.facebook.com/docs/marketing-api/guides/lead-ads/v2.9

什么都没用。我找不到关于它的不错的教程。我只想检索领先的广告!

任何人?

facebook ads facebook-php-sdk

0
推荐指数
1
解决办法
2515
查看次数

标签 统计

ads ×1

async-await ×1

axios ×1

facebook ×1

facebook-php-sdk ×1

promise ×1

rest ×1

vue.js ×1