Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check if data is an object in loadRemote. #206

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions dist/angular-gettext.js
Original file line number Diff line number Diff line change
Expand Up @@ -338,8 +338,10 @@ angular.module('gettext').factory('gettextCatalog', ["gettextPlurals", "gettextF
cache: catalog.cache
}).then(function (response) {
var data = response.data;
for (var lang in data) {
catalog.setStrings(lang, data[lang]);
if (typeof data === 'object') {
for (var lang in data) {
catalog.setStrings(lang, data[lang]);
}
}
return response;
});
Expand Down
2 changes: 1 addition & 1 deletion dist/angular-gettext.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions src/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,10 @@ angular.module('gettext').factory('gettextCatalog', function (gettextPlurals, ge
cache: catalog.cache
}).then(function (response) {
var data = response.data;
for (var lang in data) {
catalog.setStrings(lang, data[lang]);
if (typeof data === 'object') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would check the response type tbh

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hear what you are saying, but in this case the response would be an object and the status would be a 200 too. See the screenshot below.
I am willing to put in more work into this but I need some guidance from you guys.
screen shot 2017-03-10 at 2 18 06 pm

for (var lang in data) {
catalog.setStrings(lang, data[lang]);
}
}
return response;
});
Expand Down