From 6c90e8dc284a0af3d04470270ead8bf2e1292223 Mon Sep 17 00:00:00 2001 From: Ben Elferink Date: Wed, 23 Dec 2020 00:54:43 +0200 Subject: [PATCH] api base structure --- client/src/App.js | 11 +++++++++++ client/src/api/index.js | 3 +++ 2 files changed, 14 insertions(+) diff --git a/client/src/App.js b/client/src/App.js index a9099a1..75ac588 100644 --- a/client/src/App.js +++ b/client/src/App.js @@ -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
Hello World - React.js
; } diff --git a/client/src/api/index.js b/client/src/api/index.js index bb413bc..d3e3550 100644 --- a/client/src/api/index.js +++ b/client/src/api/index.js @@ -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);