Skip to content

How to debug API calls? #2312

Apr 11, 2024 · 1 comments · 2 replies
Discussion options

You must be logged in to vote

Answering my own question. In my Actors class which implements Cast:

export class Actors implements Cast {
  constructor(private readonly page: Page) {
  }

  prepare(actor: Actor) {

    const axiosInstance = createAxios({
      timeout: 10 * 1000,
    });

    axiosInstance.interceptors.request.use(request => {
      console.log("Starting Request", request);
      return request;
    })

    axiosInstance.interceptors.response.use(response => {
      console.log("Response:", response);
      return response;
    })

    return actor.whoCan(CallAnApi.using(axiosInstance))
  }

  static initialize(page: Page) {
    engage(new Actors(page));
  }
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@lostdog19
Comment options

@jan-molak
Comment options

Answer selected by lostdog19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
2 participants