首页 > 解决方案 > 有角度的 httpClient 请求持续了多长时间?

问题描述

有没有办法知道有角度的 HttpClient 请求需要多长时间才能执行?

标签: angularhttpclient

解决方案


public myRequest(): Observable<any>{
    const startTime = performance.now();
    return http.post<any>(url).pipe(
        tap(x => { 
            const endTime = performance.now();
            console.log(`Took ${endTime - startTime} to complete.`);
        })
    )
}

推荐阅读