-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Staticman submission error #35
Comments
I'm using fetch api for this. I suspect that my implementation is somewhat off. I will be looking into the same.
Thank you for this 👆 diagnosis |
Maybe the api has changed. Prior versions of staticman accepted a |
Update: Searching 'staticman fetch "application/json"', I've found this:
When a web browser parses this, it reads something like » console.log(JSON.stringify(fields))
{"fields":{"fields[name]":123,"fields[telphone]":456,"fields[classroom]":458,"fields[sex]":"dftg","fields[introduce]":"introduce","fields[college]":"this.college"}} See the {"options[slug]":"4f1f56186d2fece779068cd43c2d5eb2","fields[replyThread]":"","fields[replyID]":"","fields[replyName]":"","fields[name]":"abc","fields[email]":"dfe@er.p","fields[comment]":"skf.woelkj"} The API server can't see the top-level StaticmanAPI.prototype.requireParams = function (params) {
return function (req, res, next) {
let missingParams = []
params.forEach(param => {
if (
objectPath.get(req.query, param) === undefined &&
objectPath.get(req.body, param) === undefined
) {
missingParams.push(param)
}
})
if (missingParams.length) {
return res.status(500).send({
success: false,
errorCode: 'MISSING_PARAMS',
data: missingParams
})
}
return next()
}
} The last I've spent a day on testing. Even though it has not yet been finished, I'll take a rest and resume my work this evening. |
The problem isn't |
I seem to be hitting this 429 response ... I suppose I have to host my own instance of staticman with heroku like you've suggested on the readme. Huh 🤔 , I can relate to this sentiment Your response here also makes sense. And finally aha. Perhaps we should direct folks to host their own instance because the public instance will most likely always exceed requests quota. |
I've once written a list of documentation pages in eduardoboucas/staticman#294 (comment). Recently, Huginn theme has a section Staticman will illustrate guidelines for configuring Staticman on GitHub, GitLab and Framagit.
Heroku isn't the only choice. Other hosting guides:
Welcome to the world of distributed 💻! 😺 |
I've overlooked the commit title "还是不行?" (Still not working?) in the above code block: https://github.com/thoamsy/zerostudio/blob/b697337f97005ef6d820683df97919daa7c3d803/src/components/my-form.vue#L128-L147 After a quick glance over that repo's commit history, I thought that the example above is not so reliable, and I jumped to Staticman's official repo. The following unit test code block gives a big hint to the right request body. const fields = {
name: 'Eduardo Bouças',
email: 'mail@eduardoboucas.com',
url: 'https://eduardoboucas.com',
message: 'This is a sample comment'
} Another example: https://github.com/eduardoboucas/staticman/blob/30636040d06c64139de6dceb77c2fe32207fa981/test/unit/lib/Notification.test.js#L18-L30. Recall, from Staticman PR 219's author, that to properly test Staticman, an API client like Postman is recommended, so here's the test results in my minimal Jekyll + Staticman demo: https://git.io/smdemo.
Let's be optimistic due to recent developements/improvements of Staticman integrations in several projects, like
|
Sounds good |
Closed via #36. |
Tested with v1.0.0 at https://framagit.org/staticman-gitlab-pages/hugo-swift-theme/tree/builtv1/. The parent of the head of the branch
builtv1
is the Git SHA-1 hash for v1.0.0.The form to JSON method isn't correct, a field with empty key
"":"Comment"
is created.Besides, an
OPTIONS
type is sent to Staticman API server, which is unexpected.The text was updated successfully, but these errors were encountered: