How to use the axios.all function in axios

To help you get started, we’ve selected a few axios examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github flow-typed / flow-typed / definitions / npm / axios_v0.16.x / test_axios-v0.16.js View on Github external
firstName: 'Fred',
    lastName: 'Flintstone'
  }
}).then(r => {
  // $ExpectError
  (r.status: string);
});

class AxiosExtended extends axios.Axios {
  specialPut(...args) {
    return super.put(...args);
  }
}

const extended = new AxiosExtended();
axios.all([
  extended.specialPut('foo')
    .then((r) => {
        // $ExpectError
        (r.statusText: number)
    }),
    Promise.reject(12)
]).then(([a, b]) => {
    // $ExpectError
    (a: string);
})
github vivekratnavel / omniboard / web / src / components / App / index.js View on Github external
_fetchData = () => {
    axios.all([
      axios.get('/api/v1/database'),
      axios.get('/api/v1/Omniboard.Settings'),
      axios.get('/api/v1/Version')
    ]).then(axios.spread((dbResponse, settingsResponse, versionResponse) => {
      if (dbResponse && dbResponse.data && dbResponse.data.name) {
        this.setState({
          dbName: dbResponse.data.name
        });
      }

      if (versionResponse && versionResponse.data && versionResponse.data.version) {
        this.setState({
          appVersion: `v${versionResponse.data.version}`
        });
      }
github nishanthvijayan / CoderCalendar-API / src / runner.js View on Github external
const runner = () => axios.all([
  codeforces(),
  hackerearth(),
  hackerrank(),
  topcoder(),
  leetcode(),
  codechef(),
  atcoder(),
  csacademy(),
  coj(),
  kaggle(),
])
  .then((contestsByPlatform) => {
    const contests = flat(contestsByPlatform.filter(it => Array.isArray(it)));

    const curTime = getCurrentTimeInSeconds();
github rohan-paul / stock-dashboard-react / src / Components / StockAnalytics / Alternative-working-codes-kept-for-backup / StockAnalyticsDashBoard-WITH-HUGE-autosuggestion.js View on Github external
handleSubmitToFetchAPI = () => {
    const { stockTicker, fromDate, toDate } = this.state;
    const APIkey = process.env.REACT_APP_QUANDL_API_KEY;

    if (stockTicker !== "" && fromDate !== "" && toDate !== "") {
      const url_stockPrice = `https://www.quandl.com/api/v3/datasets/WIKI/${stockTicker}.json?start_date=${fromDate}&end_date=${toDate}&column_index=4&api_key=${APIkey}`;

      const url_stockFundamentalsValuationRatios = `https://financialmodelingprep.com/api/financial-ratios/${stockTicker}?datatype=json`;

      axios
        .all([
          axios.get(url_stockPrice),
          axios.get(url_stockFundamentalsValuationRatios)
        ])
        .then(
          axios.spread((stockPriceData, stockFundamentalsData) => {
            const receivedStockClosingData = stockPriceData.data.dataset.data;
            const closingPriceDate = receivedStockClosingData.map(i => i[0]);
            const closingPrice = receivedStockClosingData.map(i => i[1]);
            this.setState({
              xAxisData: closingPriceDate,
              yAxisData_StockClosingPrice: closingPrice,
              ySeriesDataForValuationRatios: getYSeriesDataValuationMatrix(
                stockFundamentalsData.data.financialRatios
              ),
              xSeriesDataForValuationRatios: Object.keys(
github haiwen / seahub / frontend / src / file-history.js View on Github external
]).then(axios.spread((res, res1) => {
        axios.all([
          seafileAPI.getFileContent(res.data),
          seafileAPI.getFileContent(res1.data)
        ]).then(axios.spread((content1, content2) => {
          this.setDiffContent(content1.data, content2.data);
        }));
      }));
    } else {
github lessboring / tomatoestogether / client / mockable-http.ts View on Github external
all(promises: any) {
        return axios.all(promises);
    }
github Vizzuality / gfw / app / javascript / components / widgets / land-cover / intact-tree-cover / index.js View on Github external
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;
github cityofaustin / atd-data-and-performance / webpackjs / components / MicromobilityData / index.js View on Github external
const tripSelectors = `avg(trip_duration)/60 as avg_duration_minutes, sum(trip_distance) * 0.000621371 as total_miles, avg(trip_distance) * 0.000621371 as avg_miles, count(trip_id) as total_trips`;
    const tripFilters =  `trip_distance * 0.000621371 >= 0.1 AND trip_distance * 0.000621371 < 500 AND trip_duration < 86400`;

    const dataByModeQuery = `SELECT vehicle_type, ${tripSelectors} WHERE start_time between ${dateQuery} AND ${tripFilters} GROUP BY vehicle_type`;
    const allModesQuery = `SELECT ${tripSelectors} WHERE start_time between ${dateQuery} AND ${tripFilters}`;
    const deviceCountScooterQuery = `SELECT DISTINCT device_id WHERE start_time between ${dateQuery} AND vehicle_type = 'scooter' LIMIT 1000000000`;
    const deviceCountBicycleQuery = `SELECT DISTINCT device_id WHERE start_time between ${dateQuery} AND vehicle_type = 'bicycle' LIMIT 1000000000`;
    const threeOneOneQuery = `SELECT count(sr_type_code) as count WHERE sr_created_date between ${dateQuery} AND sr_type_code == "DOCKMOBI"`;

    const dataByModeUrl = `https://data.austintexas.gov/resource/${resourceId}.json?$query=${dataByModeQuery}`;
    const allModesUrl = `https://data.austintexas.gov/resource/${resourceId}.json?$query=${allModesQuery}`;
    const deviceCountScooterUrl = `https://data.austintexas.gov/resource/${resourceId}.json?$query=${deviceCountScooterQuery}`;
    const deviceCountBicycleUrl = `https://data.austintexas.gov/resource/${resourceId}.json?$query=${deviceCountBicycleQuery}`;
    const threeOneOneUrl = `https://data.austintexas.gov/resource/${resourceId311}.json?$query=${threeOneOneQuery}`;

    axios
      .all([
        axios.get(dataByModeUrl),
        axios.get(allModesUrl),
        axios.get(deviceCountScooterUrl),
        axios.get(deviceCountBicycleUrl),
        axios.get(threeOneOneUrl)
      ])
      .then(res => {
        const dataByModeResponse = res[0].data;
        const allDataResponse = res[1].data;
        const deviceScooterDataResponse = res[2].data;
        const deviceBicycleDataResponse = res[3].data;
        const threeOneOneResponse = res[4].data;

        let bicycleData = _.filter(
          dataByModeResponse,
github mregni / EmbyStat / EmbyStat.Web / ClientApp / src / shared / services / MediaServerService.tsx View on Github external
export const searchMediaServers = async (): Promise<
  MediaServerUdpBroadcast[]
> => {
  const embySearch = axiosInstance.get(
    `${domain}server/search?serverType=0`
  );
  const jellyfinSearch = axiosInstance.get(
    `${domain}server/search?serverType=1`
  );

  return axios.all([embySearch, jellyfinSearch]).then(
    axios.spread((...responses) => {
      const servers: MediaServerUdpBroadcast[] = [];
      responses.forEach((response) => {
        if (response.status === 200) {
          servers.push(response.data);
        }
      });

      return servers;
    })
  );
};