Good evening, this is my laravels email blade file, I am trying to convert coordinates to an actual address with geocoding. When I get this delivered to an email (mailtrap.io) I believe that script is ignored, nothing shows up, only an empty DIV. I tried to create just a blank index.html page with this content, just filled out the coordinates manually and script works. And yes, I checked if {{$task->latitude}}, {{$task->longitude}} works, if I write it in a DIV it shows coordinates when I receive email. 1. Mailtraip.io ignores script tags for a security reason? 2. My mistake somewhere?
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<title>Email</title>
</head>
<body>
<div id="emailOutput">
</div>
<script type="text/javascript">
geocode();
function geocode(){
let location = 'lat:{{$task->latitude}}, lng:{{$task->longitude}}';
axios.get('https://maps.googleapis.com/maps/api/geocode/json',{
params:{
address:location,
key:'AIzaSyBqgKZ40pxXAigIXetiNjSqAGd8xtHLCJQ',
}
})
.then(function (response) {
let formattedAddress = response.data.results[0].formatted_address;
let emailOutput =
`
<h1>Your <b>work</b> device has been successfully added to database.</h1>
<p>Device ID: {{$task->deviceId}}</p>
<p>Address: ${formattedAddress}</p>
`;
document.getElementById('emailOutput').innerHTML = emailOutput;
})
.catch(function (error) {
console.log(error);
});
}
</script>
</body>
</html>