Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- "Error: gapi.client.storage is undefined"
- var apiKey = 'MY API KEY';
- var projectId = 'MY PROJECT ID FROM GOOGLE STORAGE';
- var clientId = 'MY CLIENT ID FROM GOOGLE STORAGE'
- googleCloudService.handleClientLoad(apiKey);
- googleCloudService.initializeApi('v1');
- googleCloudService.listBuckets(projectId); // <- Throws the Console Errror
- /**
- * Set required API keys and check authentication status.
- */
- this.handleClientLoad = function(apiKey) {
- gapi.client.setApiKey(apiKey);
- };
- /**
- * Load the Google Cloud Storage API.
- */
- this.initializeApi = function(apiVersion){
- gapi.client.load('storage', apiVersion).then(function success(res) {
- console.log('loaded storage api');
- },
- function error(res) {
- return alert('Error loading storage api: ' + JSON.stringify(res)); // throw error
- });
- };
- /**
- * Google Cloud Storage API request to retrieve the list of buckets in
- * your Google Cloud Storage project.
- */
- this.listBuckets = function(projectId) {
- var request = gapi.client.storage.buckets.list({ // <-- ERROR
- 'project': projectId
- });
- console.log(request);
- };
Add Comment
Please, Sign In to add comment