Skip to content

Commit

Permalink
Merge pull request #14 from ReganL/master
Browse files Browse the repository at this point in the history
Cache breaking, better dependency management and optional country code
  • Loading branch information
a7ul authored Sep 11, 2018
2 parents 5712257 + e3ead00 commit 89ddec7
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"react-native": "*"
},
"dependencies": {
"lodash": "^4.17.4"
"lodash.result": "^4.5.2"
},
"bugs": {
"url": "https://github.com/master-atul/react-native-appstore-version-checker/issues"
Expand Down
7 changes: 6 additions & 1 deletion src/fetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@ export const get = (url) => {
const config = {
method: 'GET',
credentials: 'include',
mode: 'no-cors'
mode: 'no-cors',
headers: {
'Cache-Control': 'no-cache, no-store, must-revalidate',
'Pragma': 'no-cache',
'Expires': 0
}
};
return fetch(url, config).then((response) => {
if (response.status === 200) {
Expand Down
9 changes: 5 additions & 4 deletions src/versionChecker.ios.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import result from 'lodash/result';
import _result from 'lodash.result';
import {get, parseJson} from './fetcher';

const getAppstoreAppVersion = (identifier, options = { typeOfId: 'id', country: 'us' }) => {
const url = `https://itunes.apple.com/lookup?${options.typeOfId}=${identifier}&country=${options.country}`;
const getAppstoreAppVersion = (identifier, options = { typeOfId: 'id' }) => {
const country = options.country ? `&country=${options.country}` : '';
const url = `https://itunes.apple.com/lookup?${options.typeOfId}=${identifier}${country}`;
return get(url).then(parseJson).then((d) => {
const version = result(d, 'data.results[0].version');
const version = _result(d, 'data.results[0].version');
if (!version) {
throw new Error('App not found!');
}
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
# yarn lockfile v1


lodash@^4.17.4:
version "4.17.4"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
lodash.result@^4.5.2:
version "4.5.2"
resolved "https://registry.yarnpkg.com/lodash.result/-/lodash.result-4.5.2.tgz#cb45b27fb914eaa8d8ee6f0ce7b2870b87cb70aa"

0 comments on commit 89ddec7

Please sign in to comment.