mirror of
https://github.com/rjNemo/deno_hello
synced 2026-06-06 01:56:40 +00:00
server: return detailed information
This commit is contained in:
parent
2517686f8c
commit
69d338862b
1 changed files with 2 additions and 2 deletions
|
|
@ -15,13 +15,13 @@ const serve = async (port: number) => {
|
|||
console.log(`Request on address '${req.url}'`);
|
||||
|
||||
if (parseURL(req.url) === "") {
|
||||
return req.respond({ body: sayRandomHello() });
|
||||
return req.respond({ body: JSON.stringify(sayRandomHello()) });
|
||||
}
|
||||
|
||||
try {
|
||||
const value = parseInt(parseURL(req.url), 10);
|
||||
const id = new ID(value);
|
||||
return req.respond({ body: sayHello(id) });
|
||||
return req.respond({ body: JSON.stringify(sayHello(id)) });
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return req.respond({ body: error.message });
|
||||
|
|
|
|||
Loading…
Reference in a new issue