This topic was automatically generated from Slack. You can find the original thread here.
I want to use the path to a previous step and use that in the code instead of 231225023, how do I do that?
const axios = require('axios');
// WooCommerce API URL and version
const apiURL = 'https://www.tomii.nu/wp-json/wc/v3/';
const consumerKey = 'ck_erhjore7f87d77gd7dg97gd9gd9779d9770';
const consumerSecret = 'cs_errsf46a49re7f87d77gd7dg97gd9gd9779d928';
// Endpoint for retrieving all orders
const ordersEndpoint = 'orders';
// Order number to search for
const targetOrderNumber = '231225023';
// Construct the URL for the API request
const url = `${apiURL}${ordersEndpoint}?consumer_key=${consumerKey}&consumer_secret=${consumerSecret}`;
// Make the API request to retrieve all orders
axios.get(url)
.then(response => {
// Check if the request was successful (status code 200)
if (response.status === 200) {
// Find the order with the specified order number
const targetOrder = response.data.find(order => order.number === targetOrderNumber);
if (targetOrder) {
console.log(`Found order with number ${targetOrderNumber}:\n`, targetOrder);
} else {
console.log(`Order with number ${targetOrderNumber} not found.`);
}
} else {
// Handle the error
console.error(`Error: ${response.status} - ${response.statusText}`);
}
})
.catch(error => {
// Handle request error
console.error(`Error: ${error.message}`);
});