Skip to content
This repository has been archived by the owner on Dec 3, 2021. It is now read-only.

Commit

Permalink
feat: use method provided on form action (#30)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvincrespo authored Nov 3, 2021
1 parent 96e392a commit b8a97f6
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/controllers/link_method_controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export class LinkMethodController extends Controller {
method: this.method
});

document.body.append(this.form);

return this;
}

Expand Down
2 changes: 1 addition & 1 deletion src/utils/form.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export class Form {
<input name="${this.csrf.name}" value="${this.csrf.token}" type="hidden" />
<input type="submit" />
`;
form.method = 'post';
form.method = this.method;
form.action = this.action;
form.target = this.target;
form.innerHTML = content;
Expand Down
4 changes: 3 additions & 1 deletion tests/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ fastify.register(require('point-of-view'), {
})

fastify.post('/confirm', function(req, res) {
console.log({ derp: req.body });
return res.view('confirm.ejs', { body: req.body });
});

fastify.get('/confirm', function(req, res) {
return res.view('confirm.ejs', { body: req.query });
});

fastify.listen(3000, err => {
if (err) throw err
Expand Down

0 comments on commit b8a97f6

Please sign in to comment.