Created
February 12, 2024 20:04
-
-
Save josue1dario2/9e4586e7a6798a364b51ab6129701a14 to your computer and use it in GitHub Desktop.
service de api
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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