Making your first API call
npm install axios
const axios = require('axios');
// Replace 'your_access_token_here' with your actual access token
const accessToken = 'your_access_token_here';
const config = {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${accessToken}`
}
};
// Lets create a new location
const create_location_url = new URL('https://api.skulabs.com/location/create');
const postData = {
warehouse_id: '1234',
name: 'My New Location'
};
axios.post(create_location_url.toString(), postData, config)
.then(function (response) {
console.log('Response:', response.data);
}).catch(function (error) {
console.error('Error:', error);
});
// Now, let's get the list of locations.
const get_list_url = new URL('https://api.skulabs.com/location/get_list');
const selector = { warehouse_id: '1234' };
// Append the selector to the URL
get_list_url.searchParams.append('selector', JSON.stringify(selector));
axios.get(get_list_url.toString(), config)
.then(function (response) {
console.log('Response:', response.data);
}).catch(function (error) {
console.error('Error:', error);
});