When posting to an external blog, the selected categories are sent to the Micropub server using an unrecognised key name, category[] instead of category.
This is the data sent to a server by the Micro.blog app:
{
h: 'entry',
content: 'Test categories',
'category[]': [ 'indiekit', 'indieweb' ],
'mp-destination': 'https://indiekit-sandbox.netlify.app'/,
}
However, sending the same data from another app (such as Quill) will send the following data:
{
h: 'entry',
content: 'Test categories',
category: [ 'indiekit', 'indieweb' ],
}
It looks like the app appends categories to a category[] field:
|
params.append('category[]', category) |
Using URLSearchParams.append() method multiple times adds the key value pair to a URL multiple times:
let url = new URL("https://website.example");
url.searchParams.append("category", "foo")
url.searchParams.append("category", "bar")
console.log("url", url)
// https://website.example/?category=foo&category=bar
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.
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.