Populate select tag with data from API in Vue and Axios

Stefan Bogdanescu

Founder & Senior Architect · 2026-06-29

Laravel Company
# Populate Select Tags with Data from API in Vue and Axios: A Comprehensive Guide As a senior developer working with modern JavaScript frameworks like Vue.js, fetching dynamic data from an external API using tools like Axios is a daily task. One of the most common UI requirements is populating `` options. ### Step-by-Step Implementation Example Here is how you can refactor your Vue component logic to handle this dependency cleanly. We will assume that your backend (perhaps a Laravel API) provides endpoints for both countries and cities. ```html
``` ### Key Takeaways and Best Practices 1. **Use `async/await` for Clarity:** Using `async/await` (as shown above) makes handling promises much cleaner than deeply nested `.then()` chains, especially when dealing with sequential dependent requests. 2. **Reactive Data is King:** The crucial step is ensuring that the API response is assigned to a property within the Vue `data` object (`this.cities = response.data`). Because Vue watches this data, it automatically triggers a re-render of the DOM, populating the `` from dynamic API data in a Vue environment is fundamentally about mastering reactive state management around asynchronous operations. By correctly sequencing your data fetching—fetching parent data first, then using that result to trigger dependent fetches—you can build robust, responsive user interfaces. Remember, whether you are building an application on the frontend or leveraging powerful backend services from frameworks like Laravel, clear data contracts and predictable API responses are the foundation of successful development.