Skip to content

Commit 4fb75ad

Browse files
committed
Using custom API enpoint instead of JSON
1 parent 4362a92 commit 4fb75ad

File tree

7 files changed

+19
-188
lines changed

7 files changed

+19
-188
lines changed

frontend/src/app/project/auth/auth.service.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,16 @@ import { environment } from 'src/environments/environment';
1010
export class AuthService {
1111
private baseUrl: string;
1212
constructor(private _http: HttpClient, private _store: AuthStore) {
13-
this.baseUrl = environment.API_URL;
13+
this.baseUrl = environment.apiUrl;
1414
}
1515

1616
login({ email = '', password = '' }: LoginPayload) {
1717
this._store.setLoading(true);
1818
this._http
19-
.get<JUser>(`${this.baseUrl}/auth.json`)
19+
.post<JUser>(`${this.baseUrl}/auth`, {
20+
email,
21+
password
22+
})
2023
.pipe(
2124
map((user) => {
2225
this._store.update((state) => ({

frontend/src/app/project/state/project/project.service.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export class ProjectService {
1616
baseUrl: string;
1717

1818
constructor(private _http: HttpClient, private _store: ProjectStore) {
19-
this.baseUrl = environment.API_URL;
19+
this.baseUrl = environment.apiUrl;
2020
}
2121

2222
setLoading(isLoading: boolean) {
@@ -26,7 +26,7 @@ export class ProjectService {
2626
getProject(): Subscription {
2727
this.setLoading(true);
2828
return this._http
29-
.get<JProject>(`${this.baseUrl}/project.json`)
29+
.get<JProject>(`${this.baseUrl}/project`)
3030
.pipe(
3131
map((project) => {
3232
this._store.update((state) => {

frontend/src/data/auth.json

Lines changed: 0 additions & 7 deletions
This file was deleted.

frontend/src/data/project.json

Lines changed: 0 additions & 173 deletions
This file was deleted.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export interface EnvironmentModel {
2+
production: boolean;
3+
apiUrl: string;
4+
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
export const environment = {
1+
import { EnvironmentModel } from './environment-model';
2+
3+
export const environment: EnvironmentModel = {
24
production: true,
3-
API_URL: '/data'
5+
apiUrl: 'https://jira-clone-angular-api.herokuapp.com'
46
};

frontend/src/environments/environment.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22
// `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
33
// The list of file replacements can be found in `angular.json`.
44

5-
export const environment = {
5+
import { EnvironmentModel } from './environment-model';
6+
7+
export const environment: EnvironmentModel = {
68
production: false,
7-
API_URL: '/data'
9+
apiUrl: 'http://localhost:3000'
810
};
911

1012
/*

0 commit comments

Comments
 (0)