Hi guys I'm learning how to use AMP and coming to an issue where my api requests are coming back with an empty body. My get route works fine and my post route works for non-AMP form submissions.
If someone could let me know what Im doing wrong it'd be appreciated!
HTML for the AMP form, from the amp website & contains no amp errors on load.
<form method="post" action-xhr="/subscribe" target="_top" style="width: 75%; margin: auto;">
<fieldset>
<label>
<span>Name:</span>
<input type="text" name="name" required>
</label>
<br>
<label>
<span>Email:</span>
<input type="email" name="email" required>
</label>
<br>
<input type="submit" value="Subscribe">
</fieldset>
<div submit-success>
<template type="amp-mustache">
Subscription successful!
</template>
</div>
<div submit-error>
<template type="amp-mustache">
Subscription failed!
</template>
</div>
</form>
API routes, get works fine and the post works for non-AMP forms
module.exports = function (app) {
// Subs get
app.get("/api/all", function (req, res) {
Sub.findAll({}).then(function (results) {
res.json(results);
});
});
// Subs post
app.post("/subscribe", function (req, res) {
console.log("Sub Data:");
console.log(req.body);
});
};