GET requests in components
📖 Scenario: You are building a simple Vue 3 app that shows a list of users fetched from a public API. This app will help you learn how to make GET requests inside Vue components using the Composition API.
🎯 Goal: Create a Vue component that fetches user data from https://jsonplaceholder.typicode.com/users when the component loads, and displays the users' names in a list.
📋 What You'll Learn
Use Vue 3 Composition API with
<script setup>Create a reactive variable to store the users
Make a GET request to
https://jsonplaceholder.typicode.com/users inside onMountedDisplay the users' names in an unordered list
Handle the fetch asynchronously with
async/await💡 Why This Matters
🌍 Real World
Fetching data from APIs is a common task in web apps to show dynamic content like user lists, posts, or products.
💼 Career
Understanding how to make GET requests and display data in Vue components is essential for frontend developer roles working with modern web frameworks.
Progress0 / 4 steps