const http = require('http');
const server = http.createServer((req, res) => {
if(req.url=="/feed"){
res.writeHead(200, {'Content-Type':'application/json'});
res.write(JSON.stringify({url:'kodaylak.com', postLenght: 100}));
res.end();
}
}).listen(8000);
localhost:8000/feed adresine gidersek aşağıdaki sonucu elde ederiz:

Node.js JSON Veri Döndürme
Node.js'te döndürülen veri sadece HTML değildir, JSON veri de döndürebiliriz.
Kaydol:
Kayıt Yorumları (Atom)
Hiç yorum yok:
Yorum Gönderme