📜  angular jasmin mock http response - TypeScript 代码示例

📅  最后修改于: 2022-03-11 14:48:36.541000             🧑  作者: Mango

代码示例1
public static mockGetProfile(){
    const response = JSON.parse(`
     "name": "abc",
     "active": true,
     ...all other json fields that you want
     `);

    let obs = new Observable((subscriber) => {
        setTimeout(()=>{
            subscriber.next(response);
            subscriber.complete();
        }, 3000);
    });
    return obs;
}