I don't know what's wrong with me or why this isn't working, I just want the random dog photo api to work but it's not working. See the code below.
export default { data() { return { posts: [], }; }, methods: { async getData() { try { let response = await fetch ("https://dog.ceo/api/breeds/image/random"); this.posts = await response.json(); } catch (error){ console.log(error) } } } };
You must call the
getData
function. One possible solution is that you can call thegetData
function in themounted
lifecycle hook. This is a vue playground Link