Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async componentDidMount() {
try {
const products = await RNIap.getProducts(itemSkus);
products.sort(this.compare);
this.setState({products});
console.log(products);
} catch (err) {
console.log(err); // standardized err.code and err.message available
}
}
async componentDidMount() {
if (!GITHUB_VERSION) {
try {
const products = await RNIap.getProducts(itemSkus);
// Do this just to ensure that all IAPs are available
await RNIap.consumeAllItems();
products.sort((a, b) => a.price.localeCompare(b.price));
this.setState({products});
} catch(err) {
console.warn(err); // standardized err.code and err.message available
}
}
}
_getItems = async () => {
const { skus } = this.props;
try {
const products = await RNIap.getProducts(skus);
products.sort((a, b) => parseFloat(a.price) - parseFloat(b.price)).reverse();
await this.setState({ productList: products });
} catch (err) {
bugsnag.notify(err);
Alert.alert(
`Fetching data from server failed, please try again or notify us at info@esteem.app
${err.message.substr(0, 20)}`,
);
}
await this.setState({ isLoading: false });
};
async fetchData() {
this.loading = true;
try {
const status = await RNIap.prepare();
this.products = await RNIap.getProducts(SKUs);
} catch (err) {
Sentry.captureException(err);
}
this.loading = false;
}
const products = {
'io.raindrop.pro.1month': {
title: t.s('oneMonth'),
sort: 0
},
'io.raindrop.pro.3month': {
title: t.s('threeMonth'),
sort: 1
},
'io.raindrop.pro.1year': {
title: _.capitalize(t.s('year'))+' (-20%)',
sort: 2
}
}
let found = await RNIap.getProducts(Object.keys(products))
found = found.map(product => ({
...product,
sort: products[product.productId].sort,
localizedTitle: products[product.productId].title
}))
found = _.sortBy(found, ({sort})=>sort)
return found
}