GET Ajax returns html code in response instead of json object

前端 未结 3 1275
刺人心
刺人心 2021-01-19 00:21

I have an ajax get request as below. I am making a GET request to server.js in openshift using nodejs express. However, i get html contents in the response method instead of

3条回答
  •  时光说笑
    2021-01-19 00:48

    You can use res.json to send JSON response instead of res.send

    res.json(obj)
    

    This method also set Content-Type as application/json

提交回复
热议问题