-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change server.go connection to localhost:4200
Add service.ts Edit edit question page
- Loading branch information
Showing
4 changed files
with
42 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { TestBed } from '@angular/core/testing'; | ||
|
||
import { QuestionService } from './question.service'; | ||
|
||
describe('QuestionService', () => { | ||
let service: QuestionService; | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({}); | ||
service = TestBed.inject(QuestionService); | ||
}); | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { Injectable } from '@angular/core'; | ||
import {HttpClient} from "@angular/common/http"; | ||
import {Observable} from "rxjs"; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class QuestionService { | ||
private baseUrl = 'http://localhost:8080/api/questions' | ||
constructor(private http: HttpClient) { } | ||
|
||
getQuestion(id: string): Observable<any> { | ||
return this.http.get(`${this.baseUrl}/${id}`); | ||
} | ||
|
||
updateQuestion(id: string, updatedQuestion: any): Observable<any> { | ||
return this.http.put(`${this.baseUrl}/${id}`, updatedQuestion); | ||
} | ||
} |