const axios = require('axios'); const apiConfig = require('../../config/apiConfig'); const fs = require('fs'); const fetchTicketsFromServiceNow = async () => { try { const ticketsResponse = await axios.get(apiConfig.snIncidentConfig.baseUrl, { auth: apiConfig.servicenowAuthentication.auth }); // gerar um JSON das respostas da API fs.writeFileSync('servicenow_tickets.json', JSON.stringify(ticketsResponse.data, null, 2)); } catch (error) { console.log('SERVICE NOW Tickets error: ', error.message); } } const fetchRequestsFromServiceNow = async () => { try { const requestsResponse = await axios.get(apiConfig.snRequestConfig.baseUrl, { auth: apiConfig.servicenowAuthentication.auth }); // gerar um JSON das respostas da API fs.writeFileSync('servicenow_requests.json', JSON.stringify(requestsResponse.data, null, 2)); } catch (error) { console.log('SERVICE NOW Requests error: ', error.message); } } module.exports = { fetchTicketsFromServiceNow, fetchRequestsFromServiceNow }