Moved api functions to relevant folders
This commit is contained in:
30
src/api/le-systeme-solaire/index.ts
Normal file
30
src/api/le-systeme-solaire/index.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
import axios from "axios";
|
||||
|
||||
/**
|
||||
* Fetches the API for all celestial bodies
|
||||
* @returns Array of celestials in the API
|
||||
*/
|
||||
export const fetchCelestials = (): Promise<any> => {
|
||||
return axios
|
||||
.get("https://api.le-systeme-solaire.net/rest/bodies/")
|
||||
.then(res => {
|
||||
return res.data.bodies;
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Fetches the API for all celestial bodies
|
||||
* @returns Array of celestials in the API
|
||||
*/
|
||||
export const fetchCelestial = (slug: string): Promise<any> => {
|
||||
return axios
|
||||
.get(`https://api.le-systeme-solaire.net/rest/bodies/${slug}`)
|
||||
.then(res => {
|
||||
return res.data;
|
||||
});
|
||||
};
|
||||
|
||||
export default {
|
||||
fetchCelestials,
|
||||
fetchCelestial
|
||||
};
|
||||
Reference in New Issue
Block a user