Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

921
Visualizações
ReferenceError: gapi is not defined, but I tried everything

This might sound like a dumb question because there are tons of questions of the exact same problem, but none of them could nearly help. I am using angular and in the ngAfterViewInit() I have following code: gapi.load("auth2", () => console.log("test"). I have installed @types/gapi and @types/gapi.auth2 via npm. In my tsconfig.app.json I have included "gapi" and "gapi.auth2" in the types in compilerOptions. Also in the component's html fiel I put <script src="https://apis.google.com/js/api.js"></script> in the head. I already tried to write declare var gapi: any; to the imports, but it didn't work either. Also I tried the triple slas directive /// <reference path="../../../node_modules/@types/gapi/index.d.ts"> or /// <reference types="gapi">, but none of them worked. I have no clue what to do because I tried everything that I could find in hours of research. Thanks in advance :)

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Try using a dynamic import:

import("https://apis.google.com/js/api.js").then(() => {
  gapi.load("client:auth2", () => {console.log("success")});
});
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda