api base structure
This commit is contained in:
@@ -1,7 +1,18 @@
|
||||
import React from 'react';
|
||||
import './style/style.css';
|
||||
// import * as api from './api';
|
||||
// un-comment this ^ ^ ^ to import api endpoints
|
||||
|
||||
function App() {
|
||||
// React.useEffect(() => {
|
||||
// api
|
||||
// .getSomething() // replace this with your endpoint
|
||||
// .then((response) => console.log(`✅ ${response.status} ${response.statusText}`, response.data))
|
||||
// .catch((error) => console.log(`❌ ${error}`));
|
||||
// });
|
||||
//
|
||||
// example ^ ^ ^ using the api endpoint
|
||||
|
||||
return <div>Hello World - React.js</div>;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
import axios from 'axios';
|
||||
|
||||
// customizable base-url
|
||||
const url = 'http://localhost:8080/';
|
||||
|
||||
// demonstration endpoints:
|
||||
//
|
||||
// export const getSomething = () => axios.get(url + 'path');
|
||||
// export const postSometing = (form) => axios.post(url + 'path', form);
|
||||
|
||||
Reference in New Issue
Block a user