Guest User

Untitled

a guest
Jun 29th, 2016
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. "Error: gapi.client.storage is undefined"
  2.  
  3. var apiKey = 'MY API KEY';
  4. var projectId = 'MY PROJECT ID FROM GOOGLE STORAGE';
  5. var clientId = 'MY CLIENT ID FROM GOOGLE STORAGE'
  6.  
  7. googleCloudService.handleClientLoad(apiKey);
  8. googleCloudService.initializeApi('v1');
  9. googleCloudService.listBuckets(projectId); // <- Throws the Console Errror
  10.  
  11. /**
  12. * Set required API keys and check authentication status.
  13. */
  14. this.handleClientLoad = function(apiKey) {
  15. gapi.client.setApiKey(apiKey);
  16. };
  17.  
  18. /**
  19. * Load the Google Cloud Storage API.
  20. */
  21. this.initializeApi = function(apiVersion){
  22. gapi.client.load('storage', apiVersion).then(function success(res) {
  23. console.log('loaded storage api');
  24. },
  25. function error(res) {
  26. return alert('Error loading storage api: ' + JSON.stringify(res)); // throw error
  27. });
  28. };
  29.  
  30. /**
  31. * Google Cloud Storage API request to retrieve the list of buckets in
  32. * your Google Cloud Storage project.
  33. */
  34. this.listBuckets = function(projectId) {
  35. var request = gapi.client.storage.buckets.list({ // <-- ERROR
  36. 'project': projectId
  37. });
  38. console.log(request);
  39. };
Add Comment
Please, Sign In to add comment