Skip to content

Instantly share code, notes, and snippets.

@josue1dario2
Created February 12, 2024 20:04
Show Gist options
  • Save josue1dario2/9e4586e7a6798a364b51ab6129701a14 to your computer and use it in GitHub Desktop.
Save josue1dario2/9e4586e7a6798a364b51ab6129701a14 to your computer and use it in GitHub Desktop.
service de api
import axios from 'axios';
const BASE_URL_API = 'https://erp.duxsoftware.com.ar/WSERP/rest/services';
export async function getItems(){
try{
const response = await axios({
url: `${BASE_URL_API}/items`,
method: 'GET',
headers:{
accept: 'application/json',
authorization: '2I2p6kcXxdjs4uxDtl4M5K12G8KlgnYla1lfHLqGsINq7UQb6sSwv0wver5OqqAi'
}
});
return response;
}catch(err){
console.log('getItems',err);
throw err;
}
}
export async function getByRubro(rubro){
try {
const response = await axios({
url: `${BASE_URL_API}/items`,
method: 'GET',
headers: {
accept: 'application/json',
authorization: '2I2p6kcXxdjs4uxDtl4M5K12G8KlgnYla1lfHLqGsINq7UQb6sSwv0wver5OqqAi'
}
});
const filterByCategory = response.results.filter(category => category.result.rubro == rubro);
return filterByCategory;
} catch (err) {
console.log('getByRubro', err);
throw err;
}
}
export async function getById(id) {
try {
const response = await axios({
url: `${BASE_URL_API}/items`,
method: 'GET',
headers: {
accept: 'application/json',
authorization: '2I2p6kcXxdjs4uxDtl4M5K12G8KlgnYla1lfHLqGsINq7UQb6sSwv0wver5OqqAi'
}
});
const getById = response.results.filter(category => category.result.cod_item == id);
return getById;
} catch (err) {
console.log('getById', err);
throw err;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment