* Utility method to send http request * @param {resource} resource - url part with resource name * @param {object} config - options for $http * @param {object} options - custom options (show loading, etc) * @return {promise}
(resource, config, options)
| 99 | * @return {promise} |
| 100 | */ |
| 101 | function sendRequest(resource, config, options) { |
| 102 | config = config || {}; |
| 103 | // Check if passed absolute url |
| 104 | if (resource.indexOf('http') === 0) { |
| 105 | config.url = resource; |
| 106 | } else { |
| 107 | config.url = SOUNDCLOUD_API_V2 + resource; |
| 108 | } |
| 109 | config.params = config.params || {}; |
| 110 | config.params.oauth_token = $window.scAccessToken; |
| 111 | |
| 112 | options = options || {}; |
| 113 | if (options.loading !== false) { |
| 114 | $rootScope.isLoading = true; |
| 115 | } |
| 116 | |
| 117 | return $http(config); |
| 118 | } |
| 119 | |
| 120 | /** |
| 121 | * Response success handler |