[Front-end project problem] RXJS toPromise has been deprecated (how to use the new version when toPromise is deprecated)

toPromise is deprecated how to use the new version

1. Problem Restoration

The new version of rxjs in vscode will strikethrough toPromise(), indicating that it is deprecated.
insert image description here

The official answer

insert image description here
确实在5.5版本之后已经被弃用了

3. Problem solving

import {
    
     lastValueFrom } from 'rxjs';
let res = await lastValueFrom(this.http.post(HTTP_BASE.host + AUTH_BASE, param));

insert image description here
这样就可以直接拿到接口返回的对象了

The above is the deprecated solution of toPromise, welcome to pay attention to the " Project Problems " column.
I will share the common problems in my usual projects and the knowledge of the written test and interview with you on CSDN, and make progress together. Come on.

Guess you like

Origin blog.csdn.net/weixin_46318413/article/details/123575330