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:
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.
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>
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>