[react-express-mongdb] use compose network to communicate between services (#62)

Signed-off-by: Guillaume Lours <guillaume.lours@docker.com>
master
Guillaume Lours 5 years ago committed by GitHub
parent 2f750eb4f7
commit e29f0d1c54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -13,6 +13,10 @@ services:
- /usr/src/app/node_modules
container_name: frontend
restart: always
networks:
- react-express
depends_on:
- server
server:
container_name: server
restart: always
@ -20,18 +24,24 @@ services:
context: server
args:
NODE_PORT: 3000
ports:
- 3000:3000
volumes:
- ./server:/usr/src/app
- /usr/src/app/node_modules
depends_on:
- mongo
networks:
- express-mongo
- react-express
mongo:
container_name: mongo
restart: always
image: mongo:4.2.0
volumes:
- ./data:/data/db
ports:
- 27017:27017
networks:
- express-mongo
networks:
react-express:
express-mongo:

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

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

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

Loading…
Cancel
Save