google sign-in with angular2 and typescript - where to get gapi?

前端 未结 4 505
南旧
南旧 2021-01-04 06:01

I\'m trying to use google sign-in with angular2 by following this question: Google Sign-In for Websites and Angular 2 using Typescript

But I\'m getting an error:

相关标签:
4条回答
  • 2021-01-04 06:46

    Add the following file to your project structure for removing the error.

    https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/gapi/gapi.d.ts

    This will make gapi available in your project.

    0 讨论(0)
  • 2021-01-04 06:47

    Have you included the Google platform API script?

    <script src="https://apis.google.com/js/platform.js"></script>
    

    See this question for instructions on how to wait for the GAPI script to load before executing your code.

    0 讨论(0)
  • 2021-01-04 06:54

    I also had same problem in Angular v4.0. Removing async defer from the Google platform API script solved my problem

    My Problem was like below when I used Google platform api like :

    <script src="https://apis.google.com/js/platform.js" async defer></script>
    

    I solved my problem by discarding async defer from Google platform api script as like below in my index.html :

    <script src="https://apis.google.com/js/platform.js"></script>
    
    0 讨论(0)
  • 2021-01-04 06:59

    I solved the issue by calling the following script in index.html

    <script src="https://apis.google.com/js/platform.js?onload=onLoadCallback" async defer></script>
    

    Note:

    Use the following script without async defer:

    <script src="https://apis.google.com/js/platform."></script> 
    

    and use async defer in this script

    <script src="https://apis.google.com/js/platform.js?onload=onLoadCallback" async defer></script>
    
    0 讨论(0)
提交回复
热议问题