B
B
BarneyGumble2021-03-25 13:40:48
RESTful API
BarneyGumble, 2021-03-25 13:40:48

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:
D99cbVLz.jpg?download=1&name=%D0%A1%D0%BA%D1%80%D0%B8%D0%BD%D1%88%D0%BE%D1%82%2025-03-2021%2013:40 :10.jpg

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 :
Rt4ZaALb.jpg?download=1&name=%D0%A1%D0%BA%D1%80%D0%B8%D0%BD%D1%88%D0%BE%D1%82%2025-03-2021%2013:40 :30.jpg

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

3 answer(s)
B
BarneyGumble, 2021-03-28
@BarneyGumble

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\-_]+)',

A
Anton, 2021-03-25
Semenov

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
.

V
Vladimir Kudrya, 2021-03-25
@Mugenzo

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 question

Ask a Question

731 491 924 answers to any question