Cypress Test – Check number of an api calls

describe('Check API calls', () => {
  before(() => {
    cy.visit('/home'); 
    cy.intercept({method: 'GET', url: 'api-url'}, cy.spy().as('myAlias'));
  });

  it('should only call api-url 2 times', () => {
    cy.get('@myAlias').its('callCount').should('equal', 2)    
  });
});