Skip to content

Commit

Permalink
fix: end response correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
tobyj committed Jun 8, 2023
1 parent 9085767 commit 7ec9686
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions packages/cache/nuxt/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ function createInvalidationEndpoint (driver, options) {
return;
}

const handler = async (request, response) => {
const handler = async (request, response, next) => {
try {
// Resolve handlers paths
const tags = options.handlers
Expand All @@ -28,16 +28,14 @@ function createInvalidationEndpoint (driver, options) {
tags: Array.from(new Set(tags))
});

response
.status(200)
.send('Cache invalidated successfully!');
const msg = `Cache invalidated successfully! ${tags?.toString()}`;
console.log(msg);
response.end(msg);
} catch (error) {
Logger.error('Cache driver thrown an error when invalidating cache! Operation skipped.');
Logger.error(error);

response
.status(500)
.send(`Cache driver thrown an error when invalidating cache! Operation skipped. ${error}`);
next(error);
}
};

Expand Down

0 comments on commit 7ec9686

Please sign in to comment.