Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
getAll: (arrayOfRequest) => {
return instance.all(arrayOfRequest).then(axios.spread(function(acct, perms) {
// Both requests are now complete
}));
}
};
let httpUrlPostAll = (urlList, successCallback, errorCallback) => {
let list = urlList.map(item => {
return Post(item.url, item.dataObject)
}),
resultData = new Array(urlList.length)
axios.all(list).then(axios.spread((...resultData) => {
resultData = resultData.map(item => item.data)
successCallback ? successCallback(resultData) : console.log('ๆฅๅฃๆฐๆฎ่ฏทๆฑๆๅ,ไฝๆชๅค็')
})).catch((err) => {
console.log(err)
resultData = urlList.map(item => {
return simulationData[item.url]
})
errorCallback ? errorCallback(isError ? err : resultData) : successCallback ? successCallback(isSimulationData ? resultData : errorData) : console.log('ๆฅๅฃ่ฏทๆฑๅคฑ่ดฅ')
})
}
componentDidMount() {
Axios.all([this.getPath()]).then(Axios.spread(function (path) {
this.setState({path: path.data});
}.bind(this)));
}
fetchData(rulesStat, filters) {
const stringFilters = this.buildFilter(filters);
const hash = md5(`${rulesStat.pagination.page}|${rulesStat.pagination.perPage}|${this.props.from_date}|${rulesStat.sort.id}|${rulesStat.sort.asc}|${stringFilters}`);
if (typeof this.cache[hash] !== 'undefined') {
this.processRulesData(this.cache[hash].RuleRes, this.cache[hash].SrcRes, this.cache[hash].filters);
return;
}
this.setState({ loading: true });
axios.all([
axios.get(`${config.API_URL + config.RULE_PATH}?${this.buildListUrlParams(rulesStat)}&from_date=${this.props.from_date}&highlight=true${stringFilters}`),
axios.get(`${config.API_URL + config.SOURCE_PATH}?page_size=100`),
])
.then(axios.spread((RuleRes, SrcRes) => {
if (this.state.updateCache) {
this.cachePage = rulesStat.pagination.page;
} else {
this.setState({ updateCache: true });
}
this.cache[hash] = { RuleRes, SrcRes, filters };
this.processRulesData(RuleRes, SrcRes, filters);
})).catch((e) => {
this.setState({ net_error: e, loading: false });
});
}
componentDidMount() {
axios.all([
axios.get(`${process.env.REACT_APP_LOCAL_API_URL}/genres`),
axios.get(`${process.env.REACT_APP_LOCAL_API_URL}/artists`)
]).then(axios.spread((genres, artists) => {
this.setState({
genres: genres.data,
artists: artists.data,
selectedGenre: 'Pop/Rock'
})
}));
}
onSelectGenre = (selectedGenre) => {
getData: params =>
axios
.all([
getExtent({ ...params, forestType: '' }),
getExtent({ ...params }),
getExtent({ ...params, forestType: 'plantations' })
])
.then(
axios.spread((gadm28Response, iflResponse, plantationsResponse) => {
const gadmExtent = gadm28Response.data && gadm28Response.data.data;
const iflExtent = iflResponse.data && iflResponse.data.data;
let totalArea = 0;
let totalExtent = 0;
let extent = 0;
let plantations = 0;
let data = {};
const plantationsData =
plantationsResponse.data && plantationsResponse.data.data;
plantations = plantationsData.length ? plantationsData[0].extent : 0;
if (iflExtent.length && gadmExtent.length) {
totalArea = gadmExtent[0].total_area;
totalExtent = gadmExtent[0].extent;
extent = iflExtent[0].extent;
data = {
totalArea,
export default ({ params }) => {
const { adm0, adm1, adm2, ...rest } = params || {};
const parentLocation = {
adm0: adm0 && !adm1 ? null : adm0,
adm1: adm1 && !adm2 ? null : adm1,
adm2: null
};
return axios.all([getGainGrouped({ ...rest, ...parentLocation })]).then(
axios.spread(gainResponse => {
let groupKey = 'iso';
if (adm1) groupKey = 'adm1';
if (adm2) groupKey = 'adm2';
const gainData = gainResponse.data.data;
let mappedData = [];
if (gainData && gainData.length) {
mappedData = gainData.map(item => {
const gain = item.gain || 0;
const extent = item.extent || 0;
return {
id:
groupKey !== 'iso'
? parseInt(item[groupKey], 10)
: item[groupKey],
gain,
extent,
export default ({ params }) =>
axios.all([fetchLossRanked(params), fetchExtentRanked(params)]).then(
axios.spread((lossResponse, extentResponse) => {
const { data } = lossResponse.data;
let mappedData = [];
if (data && data.length) {
mappedData = data.map(item => {
const loss = item.loss || 0;
return {
...item,
loss
};
});
}
return {
loss: mappedData,
extent: extentResponse.data.data
};
})
export default ({ params }) =>
axios
.all([
getExtent(params),
getExtent({ ...params, forestType: null, landCategory: null }),
getExtent({ ...params, forestType: 'plantations' })
])
.then(
axios.spread((response, adminResponse, plantationsResponse) => {
const extent = response.data && response.data.data;
const adminExtent = adminResponse.data && adminResponse.data.data;
let totalArea = 0;
let totalCover = 0;
let cover = 0;
let plantations = 0;
let data = {};
if (extent && extent.length) {
totalArea = adminExtent[0].total_area;
cover = extent[0].value;
totalCover = adminExtent[0].value;
data = {
totalArea,
totalCover,
cover,
plantations