Skip to content

Commit

Permalink
Getting API URL from .env file
Browse files Browse the repository at this point in the history
  • Loading branch information
avinmaster committed Dec 22, 2021
1 parent b4d1c63 commit 5df4bf8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
VUE_APP_API_URL=
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ node_modules
# local env files
.env.local
.env.*.local
.env

# Log files
npm-debug.log*
Expand Down
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
```
yarn install
```

Then, create a new `.env` file and specify the address for your API there. For example:
```
VUE_APP_API_URL=house-search.com/api
```
### Compiles and hot-reloads for development
```
yarn serve
Expand Down
2 changes: 1 addition & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default {
submit() {
this.loading = true;
axios
.post(`http://house-search.com/api/v1.0.0/search`, {
.post(`http://${process.env.VUE_APP_API_URL}/v1.0.0/search`, {
name: this.name,
minPrice: this.minPrice,
maxPrice: this.maxPrice,
Expand Down

0 comments on commit 5df4bf8

Please sign in to comment.