Router post does not work.
See original GitHub issueHi,
I am new to deno
and oak
.
The below code doesnt work for post
method but WORKS for get
.
import { Application, Router } from "https://deno.land/x/oak/mod.ts";
const router = new Router();
router
.post("/", context => {
context.response.body = "Hello world Johnson!";
});
const app = new Application();
app.use(router.routes());
app.use(router.allowedMethods());
await app.listen("127.0.0.1:8000");
Any thoughts on this? Thanks in advance.
Issue Analytics
- State:
- Created 4 years ago
- Comments:12
Top Results From Across the Web
Express router not working for post requests - Stack Overflow
when I try to access localhost:8000/api/users it returns a 404 error. You don't have a GET route to localhost:8000/api/users , you have a ......
Read more >Node js post request in route is not working - Treehouse
so im trying to get a program that im working on to use a simple post route request. Now in the program im...
Read more >Handle GET and POST Request in Express - CodeForGeek
When the user clicks on the log-in button on the HTML page we will POST the request to Server and get the response....
Read more >5.x API - Express.js
A new body object containing the parsed data is populated on the request object after the middleware (i.e. req.body ), or an empty...
Read more >Express Tutorial Part 4: Routes and controllers - MDN Web Docs
The routes are defined either using .get() or .post() methods on the router object. All the paths are defined using strings (we don't...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just to add a small detail to the explanation: If you put a URL in any browser’s URL Bar, it will always run GET against that URL endpoint. To run POST you need to use a form submit or an ajax call. Cheers!
Let me elaborate on @wujingquan’s suggestion, correct me if I’m wrong. If you want to submit a post request in a browser you need to
index.html
with this content and open it in a browserNavigating to
http://127.0.0.1:8000
in any browser will only sendGET
requests and you can’t test thePOST
functionality of your code.For more on HTTP requests check out MDN - HTTP request methods.