emailjs-com/help

Public Key not working with rest API send

Closed this issue · 1 comments

I get error:The Public Key is required. To find this ID, visit https://dashboard.emailjs.com/admin/account. When I replace the user_id with the correct public_key, I still get this error.

const url = https://api.emailjs.com/api/v1.0/email/send`

const data = {
service_id: "YOUR_SERVICE_ID",
template_id: "YOUR_TEMPLATE_ID",
user_id:"YOUR_PUBLIC_KEY",

// template_params: {
//     'from_name': 'James',
//     'message':'Hi there'
   
// }

}

export const sendEmail = async() => {
const response = await fetch(url,{
method:'POST',
cache:'no-cache',
headers:{
'ContentType':'application/json'
},
body:JSON.stringify(data)

})

return response.json()
}`

You need to replace the "YOUR_***" values and use the real keys in your code.