我希望保存从API接收的数据并将其传递到Angular中的URL?

问题描述 投票:0回答:1

我希望保存从API接收的数据并传递到Angular中的URL?

SERVICE.ts

readonly rootUrl = 'http://localhost:49940/';

constructor(private http: HttpClient) { }

getUserName(): Observable<any> {
  return  this.http.get<any>(this.rootUrl+'api/Account/GetUserClaims');
}

get(userName: string): Observable<any> {
  let URL = `https://...?codSog=${userName}`;
  return this.http.get<any>(URL);
}
angular typescript components
1个回答
0
投票

您从api获取数据:

get(item: T): Observable<T> {
  return this.http.get<T>('apiUrl');
}

保存:

save(){
  this.get().subscribe(res => this.savedItem = res,
    err => console.log(err),
    _ => console.log('item saved'));
}

发送到下一个URL:

send(item: T): Observable<T> {
  return this.http.post<T>('destinationUrl', item):
}
© www.soinside.com 2019 - 2024. All rights reserved.