angular-localization icon indicating copy to clipboard operation
angular-localization copied to clipboard

Throwing http exception

Open milindCODEROR opened this issue 6 years ago • 3 comments

As per the document, I implemented the localization but its throwing the below exception TypeError: $http.get(...).success is not a function

I am using angular: 1.6.x version

milindCODEROR avatar Aug 18 '17 12:08 milindCODEROR

Can you give an example of your code?

doshprompt avatar Aug 19 '17 15:08 doshprompt

It's because Angular 1.6 doesn't support .success. you have to use .then

https://stackoverflow.com/questions/41169385/http-get-success-is-not-a-function

alphatwit avatar Jan 16 '18 18:01 alphatwit

@doshprompt - what you should do is to replace your $http.get(...) call at line 106 with following code:

                    $http.get(url)
                        .then(function (data) {
                            var key,
                                path = getPath(token);
                            // Merge the contents of the obtained data into the stored bundle.
                            for (key in data) {
                                if (data.hasOwnProperty(key)) {
                                    root[key] = data[key];
                                }
                            }

                            // Mark the bundle as having been "loaded".
                            delete root._loading;

                            // Notify anyone who cares to know about this event.
                            $rootScope.$broadcast(localeEvents.resourceUpdates);

                            // If we issued a Promise for this file, resolve it now.
                            if (deferrences[path]) {
                                deferrences[path].resolve(path);
                            }
                        }, 
                        function (data) {
                            $log.error("[localizationService] Failed to load: " + url);

                            // We can try it again later.
                            delete root._loading;
                        });

and since the pull request is already made, it shouldn't be a hard to be implemented, I guess....

angel1st avatar Jul 10 '18 12:07 angel1st