Skip to content

Commit

Permalink
handling missing cosmos key gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
vivekjilla committed Nov 10, 2022
1 parent 31088ba commit 09f9693
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@ export async function getAllPosts() {
}

export async function getAllComments(blog_id: string) {
const queryspec = {
query: "SELECT * from c where c.blog_id = @blog_id",
parameters: [{
name: "@blog_id",
value: blog_id
}]
};
try {
const queryspec = {
query: "SELECT * from c where c.blog_id = @blog_id",
parameters: [{
name: "@blog_id",
value: blog_id
}]
};

const { resources } = await container.items.query(queryspec).fetchAll();
return resources.reverse();
const { resources } = await container.items.query(queryspec).fetchAll();
return resources.reverse();
} catch (ex) {
console.log(ex)
return []
}
}

0 comments on commit 09f9693

Please sign in to comment.