-
Notifications
You must be signed in to change notification settings - Fork 3
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
Properties with arrays are not provided correctly when posting to an external blog #53
Comments
Thanks, you're right, it should only be using the |
I haven't looked at this closely yet, but I think the issue is that the Axios framework we're using sends as JSON when we really just want plain ol' form-encoded parameters here. Micropub servers can implement both but I think there's likely better compatibility not using JSON. |
Looks like there are some solutions to sending as form encoded params here. Separately, if/when I’m able to test changes, I was thinking it might be nice to remove the Axios dependency and use the Fetch API instead, which is now supported by Node. |
I'll defer to @vincentritter on that but I'd be fine with it. We use |
Thanks @paulrobertlloyd and also thank you @manton. I'm working through this at the moment. For your benefit, when I created Gluon, I had problems sending through an array of category items, as it would do the wrong thing, this is probably because of the way it's sent using FormData. Sending an array of I need to run through more here and dig in a little, perhaps this also requires a server side change so it works as expected on Micro.blog – but the first call of action should be how the data is being sent in the first place. You'll notice that we also do the same for other parameters like multiple photos or In regards of using the fetch API... yep, it's on the list and that was my plan to eventually move away from axios. Feel free to open a PR if you want to have a go 😀 Will write an update here when I have it. |
When posting to an external blog, the selected categories are sent to the Micropub server using an unrecognised key name,
category[]
instead ofcategory
.This is the data sent to a server by the Micro.blog app:
However, sending the same data from another app (such as Quill) will send the following data:
It looks like the app appends categories to a
category[]
field:microblog-react/src/api/MicroPubApi.js
Line 170 in 5006bdc
Using
URLSearchParams.append()
method multiple times adds the key value pair to a URL multiple times:Multiple params with the same key name get serialised as an Array, so there’s no need to indicate the field is an array by adding a
[]
suffix. That’s my understanding, anyway.The text was updated successfully, but these errors were encountered: