I’m working on an app that reads form submissions and builds contact cards from that data. I have a build hook triggering this node file to run. I feel like I’m close but I’m getting a 401. Can anyone help me out here on how to make an Axios request to the Netlify API?
const axios = require('axios');
var fs = require('fs');
axios.request({
url: "https://api.netlify.com/api/v1/forms/5ff0f18977371a0007907109/submissions", //form data needed
method: "get",
baseURL: "https://app.netlify.com/authorize", //Authorization URL
auth: {
username: "$", // client_id
password: "$" // client_secret
}
}).then(function (response) {
console.log(response);
//create a file
fs.writeFile(`public/${Fname}-${Lname}.vcf`,
`
BEGIN:VCARD
...
N:${Lname};${Fname};;;
...
END:VCARD
`
, function (err) {
if (err) throw err;
console.log('Saved!');
});
}).catch(function (error) {
console.log(error);
});
Here is the production code: