Compatibility with wp.apiFetch?

I’ve been using Statify on my ClassicPress site for a while, and the latest release stopped working with errors about wp.apiFetch not being a function.

I asked over at the WP Plugin forums and the author wondered if it needs a polyfill. Edit: The WordPress forum moderators deleted the thread.

But when I went looking in the ClassicPress source, I found plenty of references to apiFetch and the specific method that’s throwing an error on my dashboard.

Uncaught TypeError: wp.apiFetch.createRootURLMiddleware is not a function
    <anonymous> https://journal.kvibber.com/wp-admin/index.php:1047
index.php:1047:30
Uncaught TypeError: wp.apiFetch is not a function
    g https://journal.kvibber.com/wp-content/plugins/statify/js/dashboard.min.js?ver=2.0.1:2
    A https://journal.kvibber.com/wp-content/plugins/statify/js/dashboard.min.js?ver=2.0.1:1
    <anonymous> https://journal.kvibber.com/wp-content/plugins/statify/js/dashboard.min.js?ver=2.0.1:2
dashboard.min.js:2:1356

So I’m a bit confused: Does ClassicPress support wp.apiFetch or not? If so, does it need to be enabled explicitly or something?

Thanks!

When you say “latest release”, are you talking about 2.7.0 stable or the nightly version?

Sorry, to clarify, I meant the latest release of the plugin, where it started using wp.apiFetch.

I’m running ClassicPress 2.7.0.

@timkaye to be noted that FAZ Cookie Manager (the version for CP) has had the same issue and the plugin developer was so kind to cooperate with us to include a polifyll into it to make it compatible with CP. I think here it’s the same issue, and I am convinced that slowly many more plugins will have same issue with apiFetch. This requires consideration - should plugins developers solve on their end or can CP do something to make it easier for them in some way?

This is ClassicPress - and it does wp-api-fetch differently from WP. That is the issue. The same issue that FAZ Cookie Manager had.
The questions is do we put a polyfill directly in core, or do we let plugin developers handle the difference between CP and WP?

ApiFetch was not intended to be part of ClassicPress. Anyway part of the code was included but was not working so it was torally removed in this pull request.

And this answers the original query - it’s the plugin developer responsibility to eventually support ClassicPress by including a polyfill.

Thanks! I’ll let the plugin dev know over on their github repo that a polyfill in the plugin is the way to go.