Answer the question
In order to leave comments, you need to log in
Why is the Wordpress REST API not returning products and product categories?
I got an application (an online store on nodejs) that works with the WP REST API (a separate backend on a separate domain and server), deployed it on my own, but it does not work completely, all pages open, except for product categories and the product cards themselves I
request the main JSON site .ru/wp-json/wc/v1 to see a list of all routes. The result of the request is successful, here is the output:
Next, I go through all the routes, they return data with a status of 200, everything except the selected ones that have a slug
If you request, say, site.ru/wp-json/wc/v1/products/tshirts , then it returns this :
In the Wordpress admin panel there are all products and all categories with the necessary slug
Tell me where to dig?
There is no doubt that the interaction with the WP REST API does not work, because some of the non-product pages work fine, which means that the application normally requests data, receives it, processes it, and gives it to the user. The cant is in the goods and categories of goods. But I don't understand what exactly
Answer the question
In order to leave comments, you need to log in
The answer was found here - https://stackoverflow.com/questions/24764212/preg-...
Escaping the minus solved the problem:
'news/(?P<slug>[\d\w-_]+)',
to'news/(?P<slug>[\d\w\-_]+)',
It seems like you need authorization or a key for Woocommerce
In any case, smoking the theme is Woocommerce API and not wordpress API
https://docs.woocommerce.com/document/woocommerce-...
https://woocommerce.github.io/woocommerce- rest-api...
Here is either https://www.npmjs.com/package/@woocommerce/woocomm... all of a sudden it will also come in handy
.
Well, if you think purely logically that it is precisely those slugs where the dynamic parameter substitution goes that do not work, then most likely the problem is in the regular season. Alternatively, you can try replacing the slug with (?P<slug>\S+)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question