1

Can someone help how can i do that?. That is the code which i get the data by fetching it, how can i export it to another file and make a query for that and render it in UI?
That is the Code:

const Cision = require('config');                 
   exports.createPressReleseasData = async (type = 'all') => {
    const listAPI = `${Cision.basePath}/papi/NewsFeed`;

    const format = `format=json`;
    let apiCall = '';
    let result = [];

    switch (type) {
      case 'press':
        apiCall = `${listAPI}/${Cision.en.pressReleases}?${format}`;
        break;
      case 'reports':
        apiCall = `${listAPI}/${Cision.en.reportReleases}?${format}`;
        break;
      case 'regulatory':
        apiCall = `${listAPI}/${Cision.en.regulatoryReleases}?${format}`;
        break;
      default:
        apiCall = `${listAPI}/${Cision.en.allReleases}?${format}`;
    }

    try {
      const response = await fetch(apiCall);
      const json = await response.json();

      result = json;
    } catch (e) {
      return 'Error', e;
    }
  };
Ahura
  • 21
  • 3
  • You can download data, make an MD file with that data and then you can put it into the content. After that, you can easily create a query with that data. – mkEagles May 08 '20 at 15:37
  • You could use something like this https://www.gatsbyjs.org/packages/gatsby-source-apiserver/ – ksav May 08 '20 at 16:07
  • @mkEagles could you make a clear example how you do it actually? – Ahura May 09 '20 at 09:59

0 Answers0