I'm sorry if I'm missing something obvious like having " instead of ' but I tried many different ways and it still does the same thing, i.e. displays the actual javascript code, instead of the functionality, when I put it inside a .html file or gives me this error: Parse error: syntax error, unexpected '<' in E:\XAMPP\htdocs\website2\test.php on line 9 When I place it inside of a php file.
Here's the code:
<!DOCTYPE html>
<html>
<head>
    <script src="js.js" type="text/javascript"></script>
    <title>TEST</title>
</head>
<body>
<?php 
    echo '<script type="text/javascript">
    var https = require("https");
var username = "04d2ac7f76a0fbc0eee9dc5ef96b9259";
var password = "dc70ffc7ad911236bc2e0822855e2d42";
var auth = "Basic " + new Buffer(username + ':' + password).toString('base64');
var request = https.request({
    method: "GET",
    host: "api.intrinio.com",
    path: "/companies?ticker=AAPL",
    headers: {
        "Authorization": auth
    }
}, function(response) {
    var json = "";
    response.on('data', function (chunk) {
        json += chunk;
    });
    response.on('end', function() {
        var company = JSON.parse(json);
        console.log(company);
    });
});</script>'; 
?>
</body>
</html>
 
     
     
     
    