Newer
Older
import { HttpClient, HttpParams, HttpHeaders } from '@angular/common/http';
import { Observable } from 'rxjs';
import { SERVER_API_URL } from 'app/app.constants';
@Injectable({ providedIn: 'root' })
public resourceUrl = SERVER_API_URL + 'api/exerciseFile/';
public loadExerciseFile(exerciseId: string, filePath: string): Observable<string> {
const headers = new HttpHeaders(); // .set('Content-Type', 'text/plain; charset=utf-8');
const options: HttpParams = new HttpParams();
options.append('filePath', filePath);
return this.http.get<string>(this.resourceUrl + exerciseId, {
headers,
params: new HttpParams().set('filePath', filePath),
responseType: 'text' as 'json'
});