This topic is talk about woocommerce and react integration.
Environment
Local environment with SSL
Tools
MAMP
WordPress Setup
Setup a wordpress with woocommerce plugin, generate a self sign certificate store in project folder ssl.
React Library
You can find more information from github
yarn add @woocommerce/woocommerce-rest-api
Modify package.json
"start": "HTTPS=true SSL_CRT_FILE=[path_to_your]/ssl/shirtstore.com.crt SSL_KEY_FILE=[path_to_your]/ssl/shirtstore.com.key react-scripts start"
Call For API
const api = new WooCommerceRestApi({
url: "https://localhost.com",
consumerKey: "ck_xxxxxx",
consumerSecret: "cs_xxxxxx",
version: "wc/v3"
});
useMemo(() => {
async function fetchData() {
ap.iget("products/categories", {
"parent": "0",
"exclude": [15, 221]
}).then((response) => {
setOptions(response.data);
}).catch((error) => { });
}
fetchData();
}, []);
Woocommerce rest api + React dev + local ssl