Nuxt/test/fixtures/basic/pages/validate-async.vue

22 lines
425 B
Vue
Raw Normal View History

2018-08-25 09:42:00 +00:00
<template>
<h1>I am valid</h1>
</template>
<script>
export default {
validate ({ query }) {
return new Promise((resolve, reject) => {
2018-08-25 09:42:00 +00:00
setTimeout(() => {
if (query.error) {
const err = new Error('Custom Error')
err.statusCode = parseInt(query.error) || 500
reject(err)
} else {
resolve(Boolean(query.valid))
}
2018-08-25 09:42:00 +00:00
}, 500)
})
}
}
</script>