user.service.ts 520 B

1234567891011121314151617
  1. import { Injectable } from '@angular/core';
  2. import { HttpClient } from '@angular/common/http';
  3. import { Observable } from 'rxjs';
  4. @Injectable({
  5. providedIn: 'root'
  6. })
  7. export class UserService {
  8. private apiUrl = 'http://127.0.0.1:4040/apps/DevServer/browser/survey'; // 替换为你的 API URL
  9. constructor(private http: HttpClient) {}
  10. // 获取当前用户信息
  11. getCurrentUser(): Observable<any> {
  12. return this.http.get(`${this.apiUrl}/current-user`); // 假设这个 API 返回当前用户的信息
  13. }
  14. }