wjflew
#1
Can someone please tell me what I did wrong and point me in the right direction? It should countdown from 5, 4, 3, 2, 1, Kaboom!
Thanks in advance.
import { serve } from "https://deno.land/std@0.120.0/http/server.ts";
let count = 6;
let message = "Start over.";
const handleRequest = (request) => {
const url = new URL(request.url);
if (url.pathname === "/count") {
count--;
return new Response(count);
} else if (count <= 0) {
return new Response("Kaboom!")
}
return new Response(message);
};
serve(handleRequest, { port: 7777 });
Please post your code instead of a picture - thanks.
Thanks. What’s the current behavior you’re seeing? Is there a live demo of this up somewhere?
Note: I’m not an expert in this, but the basic logic seems ok, so its probably some smaller detail?
wjflew
#5
Ohhhh, I see it
Here
this behavior is always taken if the pathname is /count
so this part will never occur if the pathname is /count
wjflew
#7
Gotcha!! I see what you mean. I’m gonna work on it a bit more now that I know where the problem is. I’ll update when I solve it! Thank you!
1 Like
Cool! Let us know if you have more questions!
1 Like
system
Closed
#9
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.