I'm trying to send a post request. But the API returns undefined, and I send it to my API, as it turned out [object Object]
getAccouting():Observable<any>{
// let json = this.http.get<any>('/assets/cities/altayskiy_kray/accounting.json'); if i use it json return undefined
let json;
this.http.get('/assets/cities/altayskiy_kray/accounting.json').pipe(data=>json=data);
let formData:FormData = new FormData;
formData.append('json', json);
return this.http.post<any>('http://api/api.php', formData);
}
How fix that?
this.http.get().pipe( mergeMap(response: Response => this.http.get(response.doSomething()) ). The docs forswitchMap()operator are a good starting point too learnrxjs.io/learn-rxjs/operators/transformation/switchmap