1
0
Fork 0
mirror of https://github.com/docker/awesome-compose.git synced 2025-04-28 23:31:47 +02:00

[react-express-mongdb] use compose network to communicate between services

Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
This commit is contained in:
Guillaume Lours 2020-05-12 10:55:30 +02:00
parent 2f750eb4f7
commit 9cb2a73ee5
4 changed files with 20 additions and 20 deletions

View file

@ -25,6 +25,7 @@
"eslintConfig": {
"extends": "react-app"
},
"proxy": "http://server:3000",
"browserslist": {
"production": [
">0.2%",

View file

@ -1,5 +0,0 @@
const config = {
API_BASE_URL: 'http://localhost:3000',
};
export default config;

View file

@ -1,12 +1,10 @@
import axios from 'axios';
import config from '../config/constants';
export async function request (method, uri, data, headers = null, params = null) {
let url = (config.API_BASE_URL + uri);
export function request (method, uri, data, headers = null, params = null) {
let query = {
method: method,
url: url
method,
url: uri
};
if (headers !== null)
query.headers = headers;
@ -14,9 +12,5 @@ export async function request (method, uri, data, headers = null, params = null)
query.params = params;
if (method === 'post' || method === 'put' || method === 'delete' || method === 'patch')
query.data = data;
try {
return await axios(query);
} catch (e) {
throw e;
}
}
return axios(query);
}