A different vision
At this point, our app is functioning just fine. We can improve our app experience by making sure we can handle situations when the API returns an error. Let’s see how we can make our app a bit more robust in that sense.
We’ll add a page that will be able to display errors to the user when they occur. Let’s start with a new file in the views
folder called ErrorView.vue
. Just create a template with the following contents:
<template> <main> Oops! </main> </template>
We’ll circle back to this file later. We can now at least create a new route in the router/index.ts
file, which just duplicates similar logic from the search
route:
import { createRouter, createWebHistory } from 'vue-router'import HomeView from '../views/HomeView.vue' const router = createRouter({ history: createWebHistory(import.meta.env.BASE_URL), routes...