server/database/download-police-employment-data.js
// Retrieve Police Employment Data for the United States
Retrieve Police Employment Data for the United States
Retrieve Police Employment Data for the United States
function downloadAllPoliceEmploymentData() {
  return axios({
    method:'get',
    url:`https://api.usa.gov/crime/fbi/sapi/api/police-employment/national?api_key=iiHnOKfno2Mgkt5AynpvPpUQTEyxE77jo1RU8PIv`,
    responseType:'stream'
  })
  .then((response) => {
    response.data.pipe(fs.createWriteStream(`/Users/jefflewis/Documents/Computer-Programming/Projects/Converted GraphQL REST APIs/fbi-crime-data-rest-api-to-graphql/database/employment-data/police-employment/all-united-states/united-states-police-employment.json`))
  })
  .catch((error) => console.log(error));
}
function downloadAllPoliceEmploymentData ( ) { return axios ( { method : 'get' , url : ` ` , responseType : 'stream' } ) . then ( ( response ) => { response . data . pipe ( fs . createWriteStream ( ` ` ) ) } ) . catch ( ( error ) => console . log ( error ) ) ; }
Retrieve Police Employment Data for the United States
Retrieve Police Employment Data for the United States
// Axios: GET Request // Write response to .json file and store in the database // Error Handling