When learning Nodejs, it is customary to use write () to output results in the browser, but when the output is an object, there is a bit of trouble.
Code
varhttp= require(' http ');http.Createserver(function(Request,Response{ Response.Writehead( $,{"Content-type":"Text/html;charset=utf-8"}); if(Request.URL != '/favicon.ico '){ varObj= {"Aid":"123","CID":"5"}; //Console.log (obj); Console output {aid: ' 123 ', cid: ' 5 '} Response.Write(obj); //Error } Response.End();}).Listen(8088);Console.Log(' Done ');
Such a Shingwen is not good for my eyes, but I can see that First argument must be a string or Buffer there is a response.write() problem with the parameters.
I thought about it.document.write()
No problem, is it response.write() more than document.write() sentimental??
Silently changed toresponse.write(JSON.stringify(obj));
You win, I endorse ...
First entry Nodejs--Response.Write object times wrong