Content-Type

es kann z. B. Text, HTML Code, Daten (JSON), oder eine Datei zurück gesendet werden

  • Plain Text

    Coderesponse.setHeader("Content-Type", "text/plain");
    response.end("Hello World");
    
  • HTML Code

    Coderesponse.setHeader("Content-Type", "text/html");
    response.end("<html><body><h2 style='color:green'>Hello World</h2></body></html>");
    
  • JSON Daten

    Coderesponse.setHeader("Content-Type", "application/json");
    const info = { info: "Hello World"};
    response.end(JSON.stringify(info));