Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async canActivate({ postSlug }) {
try {
const { data: { post } } = await query(`query {
post(slug: "${postSlug}") {
id,
title,
body
}
}`) as ApolloQueryResult;
this.post = post;
} catch (e) {
throw new Error('Could not load post');
}
}
}
async activate() {
try {
const { data: { posts } } = await query(`query {
posts() {
id,
title,
body
}
}`) as ApolloQueryResult;
this.posts = posts;
} catch (e) {
throw new Error('Could not load posts');
}
}
}