api base structure

This commit is contained in:
Ben Elferink
2020-12-23 00:54:43 +02:00
parent 16df9f7e96
commit 6c90e8dc28
2 changed files with 14 additions and 0 deletions

View File

@@ -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>;
}

View File

@@ -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);