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

有些话、适合烂在心里 提交于 2019-11-30 17:44:08

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.

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>

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.

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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!