You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

33 lines
743 B

<template>
<div>
<h1>Continent: {{ continent }}</h1>
<h2>Mountain: {{ mountain }}</h2>
<p>Path: {{ $route.path }}</p>
<NuxtLink to="/">
Back to Mountains
</NuxtLink>
</div>
</template>
<script>
export default {
async asyncData ({ params, redirect }) {
const mountains = await fetch(
'https://api.nuxtjs.dev/mountains'
).then(res => res.json())
const filteredMountain = mountains.find(
el =>
el.continent.toLowerCase() === params.continent &&
el.slug === params.mountain
)
if (filteredMountain) {
return {
continent: filteredMountain.continent,
mountain: filteredMountain.title
}
} else {
redirect('/')
}
}
}
</script>