Skip to content

Commit d6dfa4a

Browse files
committed
Change API to REACT_APP_API
1 parent 0106476 commit d6dfa4a

4 files changed

Lines changed: 16 additions & 26 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"styled-components": "^4.3.2"
1515
},
1616
"scripts": {
17-
"start": "react-scripts start",
17+
"start": "REACT_APP_API=http://localhost:5000 react-scripts start",
1818
"build": "react-scripts build",
1919
"test": "react-scripts test",
2020
"eject": "react-scripts eject"

src/containers/DetailsService/index.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ const DetailsService = ({ id }) => {
112112
})
113113

114114
const { title, description, week, site, address, district, photo } = service
115-
const { API } = process.env
115+
const { REACT_APP_API } = process.env
116116

117117
const printDay = day => {
118118
try {
@@ -126,9 +126,7 @@ const DetailsService = ({ id }) => {
126126

127127
useEffect(() => {
128128
async function getService() {
129-
const res = await axios.get(
130-
`${API || 'http://localhost:5000'}/business/${id}`
131-
)
129+
const res = await axios.get(`${REACT_APP_API}/business/${id}`)
132130
setService(res.data)
133131
}
134132

src/containers/MainMenu/index.js

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,10 @@ const MainMenu = ({ active, closeMenu, openMenu, updateBusiness }) => {
99
const [categories, setCategories] = useState([])
1010

1111
useEffect(() => {
12-
const { API_HOST } = process.env
12+
const { REACT_APP_API } = process.env
1313
const featchData = async () => {
14-
const res = await axios.get(
15-
`${API_HOST || 'http://localhost:5000'}/category`
16-
)
17-
console.log('URL', `${API_HOST || 'http://localhost:5000'}/category`)
14+
const res = await axios.get(`${REACT_APP_API}/category`)
15+
console.log('URL', `${REACT_APP_API}/category`)
1816
console.log('category', res.data)
1917

2018
setCategories(() => res.data)
@@ -24,21 +22,18 @@ const MainMenu = ({ active, closeMenu, openMenu, updateBusiness }) => {
2422
}, [])
2523

2624
useEffect(() => {
27-
const { API } = process.env
25+
const { REACT_APP_API } = process.env
2826

2927
const getServicesByActiveCategories = async () => {
3028
const activeCategories = categories
3129
.filter(category => category.active)
3230
.map(category => category.content)
3331

34-
const { data } = await axios.get(
35-
`${API || 'http://localhost:5000'}/business/categories`,
36-
{
37-
params: {
38-
categories: activeCategories
39-
}
32+
const { data } = await axios.get(`${REACT_APP_API}/business/categories`, {
33+
params: {
34+
categories: activeCategories
4035
}
41-
)
36+
})
4237

4338
updateBusiness(data)
4439
}

src/containers/ServiceForm/index.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,13 @@ const ServiceForm = () => {
2828
})
2929
const [categories, setCategories] = useState([])
3030
const [photo, setPhoto] = useState()
31-
const { API } = process.env
31+
const { REACT_APP_API } = process.env
3232

3333
const send = async () => {
3434
const {
3535
data: { location }
36-
} = await axios.post(
37-
`${API || 'http://localhost:5000'}/business/photo`,
38-
photo
39-
)
40-
await axios.post(`${API || 'http://localhost:5000'}/business`, {
36+
} = await axios.post(`${REACT_APP_API}/business/photo`, photo)
37+
await axios.post(`${REACT_APP_API}/business`, {
4138
...service,
4239
photo: location
4340
})
@@ -74,12 +71,12 @@ const ServiceForm = () => {
7471

7572
useEffect(() => {
7673
async function getAllCategories() {
77-
const res = await axios.get(`${API || 'http://localhost:5000'}/category`)
74+
const res = await axios.get(`${REACT_APP_API}/category`)
7875
setCategories(res.data)
7976
}
8077

8178
getAllCategories()
82-
}, [API])
79+
}, [])
8380

8481
return (
8582
<WrapperCard>

0 commit comments

Comments
 (0)