~ node contato.js
# hover to see the full function
contact('me.json')
~ cat me.json
{
"name": "Pedro Henrique",
"email":
"pedro_hga@proton.me",
"currentLocation": "São Paulo, Brazil",
"mobile": "+55 11 986-786-862",
"linkedin":
"in/pedrohga",
"github":
"pedro-hga"
}
# feel free to say hi!
async function contact(json) {
try {
const response = await fetch(json);
if (!response.ok) {
throw new Error('Failed to fetch the JSON file.');
}
const personalInfo = await response.json();
return JSON.stringify(personalInfo, null, 2);
} catch (error) {
return { error: error.message };
}
const recipient = json.email
const subject = 'Hi!';
const body = 'Write your email here';
const mailTo = `mailto:${recipient}?subject=${encodeURIComponent(subject)}&body=${encodeURIComponent(body)}`;
}
contact('me.json')