Can the package @wordpress/api-fetch also be used on the frontend? #38137
-
Can we use |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Yes, you should be able to use I don't know how much of that is related to the block editor so you need to find your ideal setup.
I guess it's also fine. In particular, when you only want to perform requests for logged out users where handling for nonces would be useful. |
Beta Was this translation helpful? Give feedback.
Yes, you should be able to use
@wordpress/api-fetch
also on the front end. It requires some configuration but you can check how it's done in the admin here:https://github.com/WordPress/wordpress-develop/blob/b8f97013df4fb461c72ebf7d0b5166bac15a526b/src/wp-includes/script-loader.php#L294-L323
I don't know how much of that is related to the block editor so you need to find your ideal setup.
I guess it's also fine. In particular, when you only want to perform requests for logged out users where handling for nonces would be useful.