This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

Themabewertung:
  • 0 Bewertung(en) - 0 im Durchschnitt
  • 1
  • 2
  • 3
  • 4
  • 5
Formulareingabe mithilfe von Server zurückgeben - klappt nicht..
#1
Hey zusammen, ich möchte zunächst einmal nur eine Formulareingabe mithilfe von fetch speichern und wieder zurückgeben.

Nun finde ich den Fehler aber nicht und weiß mir nicht mehr weiter zu helfen. 
Vielleicht könnt ihr mir helfen.
Danke!

const http = require ('http');

const hostname='127.0.0.1';
const port = 3000;

//const url= new URL (request.url | '', `http://${request.headers.port}`)

const server = http.createServer((request, response) => {

    switch(url.pathname){
        case "/vorname":            //--> pfad angeben, wenn daten kommen, dann abfragen 
         if(request.method =="POST"){
           let jsonString ='';
                request.on ('data',(data) => {
                    jsonString+=data })             // werden gesammelt 
            request.on('end', () =>{
                const id = JSON.parse (jsnonString);
                console.log("Vorname", Vorname)
                response.end('Vorname', Vorname); // schickt antwort los an Client 
            })             
         }
                                                                   // was mache ich mit den daten die ankommen
            break; }

        }
    }


server.listen(port, hostname, ()=>{
    console.log(`Server running at http://${hostname} : ${port}/`)
})




Viele Grüße!
Zitieren
#2
Ist das nodejs ?
Da bin ich noch nicht gut drinn, da solltest du mal in einem Forum fragen die nur mit node arbeiten.
Ich kann da noch nicht viel bei Helfen weil ich auch nicht ganz verstehe was du mit speichern meinst usw...
Hier sind alle meine Lösungen aus allen Foren. Ich helfe auch in Facebook-chat
Als Lösung markieren Zitieren


Gehe zu:


Benutzer, die gerade dieses Thema anschauen: 1 Gast/Gäste