Php REST服务器响应javascript浏览器错误(HTML),而不是json

Php REST服务器响应javascript浏览器错误(HTML),而不是json,php,json,node.js,server,aws-lambda,Php,Json,Node.js,Server,Aws Lambda,我使用Node.js(在AWS Lambda for alexa skill上)请求web服务器提供JSON文件。但我的服务器会以“Javascript”不受支持的错误html进行响应 这是我的代码: function httpsGet(myData, callback) { // Update these options with the details of the web service you would like to call var options = {

我使用Node.js(在AWS Lambda for alexa skill上)请求web服务器提供JSON文件。但我的服务器会以“Javascript”不受支持的错误html进行响应

这是我的代码:

function httpsGet(myData, callback) {
    // Update these options with the details of the web service you would like to call
    var options = {
        host: 'alexa0788.byethost24.com',
        port: 80,
        path: '/sample.php',
        method: 'GET',
    };

    var req = http.request(options, res => {
        res.setEncoding('utf8');
        var returnData = "";

        res.on('data', chunk => {
            returnData = returnData + chunk;
        });

        res.on('end', () => {

            console.log(returnData);
            var pop = JSON.parse(returnData).firstName + JSON.parse(returnData).lastName;

            callback(pop);  // this will execute whatever function the caller defined, with one argument

        });

    });
    req.end();
}

我如何让我的服务器响应预期的json,而不强制客户机支持javascript?目前,我有一个php文件输出json。我尝试过直接调用.json文件,而不是让php文件输出json,但我看到了相同的错误

这应该在服务器端进行更改。问题在于您的alexa0788.byethost24.com,而不是您的nodeJS应用程序。因此,我问如何让我的服务器用json而不是html响应。。我用其他服务器验证了NodeJS,它可以工作。这纯粹是一个PHP问题。先看看吧。