node-desleri-by105
Version:
du bir deneme sürümüdür. 22222
39 lines (26 loc) • 1.25 kB
JavaScript
const https = require("https")
https.get("https://restcountries.eu/rest/v2/name/turkey", (response) => {
let data = "";
response.on("data", chunk => {
console.log(chunk);
console.log("--------------------------------------------------------------------------------------------")
data = data + chunk
});
response.on("end", _ => {
const jsonData= JSON.parse(data);
if(jsonData[0] != null){
console.log(data)
console.log("------------------------------------------------------------------------------------------------------------------")
console.log(jsonData[0].name)
console.log("------------------------------------------------------------------------------------------------------------------")
console.log(jsonData[0].timezones[0]);
console.log("------------------------------------------------------------------------------------------------------------------")
console.log(jsonData[0].currencies[0].name)
}else{
console.error("hata verdi")
}
})
}).on("error",err => {
console.log(err.message);
});
// burası baya önemli