Hi!
I’m loading JavaScript into an XWiki page which modifies an XObject and saves it when the page is saved. The save call gets an HTTP 202 status. Sometimes the XObject is not actually updated. The server logs no error.
My code looks something like this:
require(["xwiki-meta"], (xwikiMeta) => {
// load XObject, render custom widget, update the XObject properties based on user input
document.observe("xwiki:actions:beforeSave", async () => {
await fetch(`${xwikiMeta.restURL}/objects/Integrations.Code.FunctionalityClass/${xObject.number}?media=json`,
{
method: "PUT",
headers: { "content-type": "application/json" },
body: JSON.stringify(xObject),
}
)
})
}
The XObject I save is not the main page object. That one is saved by the usual form submit.
What could be the reason it only sometimes works? Does my code make sense or am I doing something wrong?
Thanks!
Yves