"res.write prints html tags as text in express" Code Answer's
You're definitely familiar with the best coding language TypeScript that developers use to develop their projects and they get all their queries like "res.write prints html tags as text in express" answered properly. Developers are finding an appropriate answer about res.write prints html tags as text in express related to the TypeScript coding language. By visiting this online portal developers get answers concerning TypeScript codes question like res.write prints html tags as text in express. Enter your desired code related query in the search bar and get every piece of information about TypeScript code related question on res.write prints html tags as text in express.
res.write prints html tags as text in express
const express = require("express");
const https = require("https");
const app = express();
const url =
"https://api.openweathermap.org/data/2.5/weather?q=London,uk&units=metric&appid=0333cb6bfed722ca09f1062ec1ea9ca1";
app.get("/", (req, res) => {
https.get(url, response => {
response.on("data", data => {
const weatherData = JSON.parse(data);
const temp = weatherData.main.temp;
const { description, icon } = weatherData.weather[0];
const imageURL = `http://openweathermap.org/img/wn/${icon}@2x.png`;
res.set("Content-Type", "text/html");
//OR
res.setHeader("Content-Type", "text/html");
res.send(`
<h3>The weather is currently ${description}</h3>
<img src="${imageURL}">
<h1>The temperature in London is <span>${temp}</span> ° Celsius.</h1>
`);
});
});
//res.send('server is up!!!');
});
app.listen(3000, () => {
console.log("Server started!!!");
});
Source: stackoverflow.com
All those coders who are working on the TypeScript based application and are stuck on res.write prints html tags as text in express can get a collection of related answers to their query. Programmers need to enter their query on res.write prints html tags as text in express related to TypeScript code and they'll get their ambiguities clear immediately. On our webpage, there are tutorials about res.write prints html tags as text in express for the programmers working on TypeScript code while coding their module. Coders are also allowed to rectify already present answers of res.write prints html tags as text in express while working on the TypeScript language code. Developers can add up suggestions if they deem fit any other answer relating to "res.write prints html tags as text in express". Visit this developer's friendly online web community, CodeProZone, and get your queries like res.write prints html tags as text in express resolved professionally and stay updated to the latest TypeScript updates.