如何等待订阅事件在路由之前完成

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

[我目前正在执行POST方法,并使用一些参数路由我的应用程序,但问题似乎是应用程序在POST方法完成之前进行了路由并带有响应。

我的职能:

    let responseBody;

    let postUploads = function() {
      return this.http.post(url, uploadFile).pipe((response: any) => this.responseBody = response);
    }

    postUploads().subscribe(() => this.router(['/inbox], { queryParams: {file: responseBody} }));

正在发生的问题是它进入了从POST作为响应返回“ responseBody”之前的路由>

在路由用户之前,我如何使其等待响应返回?

我当前正在执行POST方法,并使用一些参数路由我的应用程序,但问题似乎是应用程序在POST方法完成之前进行了路由,并带有响应。我的...

angular http post routing rxjs
1个回答
0
投票

您引用的是错误的responseBody

© www.soinside.com 2019 - 2024. All rights reserved.