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;
}
};