I am building an ecommerce mobile app with react native and woocommerce and i an facing this issue.. per_page doesn’t work
This is the code
import WooCommerceAPI from 'react-native-woocommerce-api';
const WooCommerce = new WooCommerceAPI({
url: 'http://example.com/', // Your store URL
ssl: false,
consumerKey: 'ck_xxxxxxxxxxx', // Your consumer key
consumerSecret: 'cs_xxxxxxxxxxx', // Your consumer secret
wpAPI: true, // Enable the WP REST API integration
version: 'wc/v3', // WooCommerce WP REST API version
queryStringAuth: true
});
Then
componentDidMount() {
WooCommerce.get('products?per_page=50', {})
.then(res => {
this.setState({
data: res,
isLoading: false
});
})
.catch(error => {
console.log(error);
this.setState({
error,
isLoading: true
});
});
}
and then
console.log(this.state.data);
and i got this in console
Object {
“code”: “woocommerce_rest_authentication_error”,
“data”: Object {
“status”: 401,
},
“message”: “Invalid signature – provided signature does not match.”,
}
If i write WooCommerce.get('products', {})
it gets 10 products as a max limit from woocommerce API but i need to get all products
3
Answers
Open react-native-woocommerce-api.js in node_modulesreact-native-woocommerce-apilib
then goto line 195 (_getOAuth().authorize function) and change:
to
Older API version
Hope this helps
this should work!