Closed botoxparty closed 5 years ago
LMAO nevermind I worked it out.
In my apiFetch i was passing options.data
for all my POST requests, however the media ones you need to pass options.body
in the request.
Any ideas on receiving upload permissions on init?
Hi @botoxparty,
Is your apiFetch
expecting requests for OPTIONS wp/v2/media
? I'm asking this because it's not so obvious at first sight.
You can check our implementation in g-editor. I hope this can help you.
Hey Sofia,
It is but my implementation is slightly different, I actually send the request to WP to fullfill.
if (options.method === "OPTIONS") {
const { data } = await optionsWordpressData(options.path);
return new Promise(resolve => {
resolve(data);
});
I'll modify this tonight to check options.path
and return true
if its wp/v2/media
Thanks for your help.
Works perfect! Thank you!
So I still can't get it to work with the media route in WP API.
I also still have to force allowing media uploads by calling
data.dispatch("core").receiveUploadPermissions(true);
after the editor has loaded.This is the response from the post request to
/wp-json/wp/v2/media