Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit d7d1aa7

Browse files
committed
Add url based on envirment for API
1 parent eac2f51 commit d7d1aa7

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { Injectable } from '@angular/core'
22
import { HttpClient } from '@angular/common/http'
33
import { Product } from '../models/product'
4+
import { environment } from 'src/environments/environment'
45
@Injectable({
56
providedIn: 'root',
67
})
78
export class ProductService {
89
constructor(private http: HttpClient) {}
910

1011
getProducts(): Promise<Product[]> {
11-
return this.http.get<Product[]>('http://localhost:9000/.netlify/functions/products').toPromise()
12+
return this.http.get<Product[]>(environment.apiUrl+'products').toPromise()
1213
}
1314
}

‎src/environments/environment.prod.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export const environment = {
2-
production: true
3-
};
2+
production: true,
3+
apiUrl: 'https://ng-serverless-faunadb.netlify.app/.netlify/functions/',
4+
}

‎src/environments/environment.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@
33
// The list of file replacements can be found in `angular.json`.
44

55
export const environment = {
6-
production: false
7-
};
6+
production: false,
7+
apiUrl: 'http://localhost:9000/.netlify/functions/',
8+
}
89

910
/*
1011
* For easier debugging in development mode, you can import the following file

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /