feat: add action class to connect the api mongo - getAll
This commit is contained in:
13
src/api/actions.jsx
Normal file
13
src/api/actions.jsx
Normal file
@@ -0,0 +1,13 @@
|
||||
export async function getExternalData() {
|
||||
try {
|
||||
const response = await fetch('http://portainer.white-enciso.pro:4001/api/v1/MongoSample/GetAll');
|
||||
if (!response.ok) {
|
||||
throw new Error(`HTTP error! status: ${response.status}`);
|
||||
}
|
||||
const data = await response.json();
|
||||
return data;
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch data:', error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user