malxau / yori

Yori is a CMD replacement shell that supports backquotes, job control, and improves tab completion, file matching, aliases, command history, and more.
http://www.malsmith.net/yori/
MIT License
1.25k stars 31 forks source link

throw er; // Unhandled 'error' event #119

Open Tobi-Babalola123 opened 1 year ago

Tobi-Babalola123 commented 1 year ago

const express = require("express"); const bodyParser = require("body-parser"); const request = require("request"); const https = require("https");

const app = express();

app.use(express.static("public")); app.use(bodyParser.urlencoded({extended: true}));

app.get("/", function(req, res) { res.sendFile(__dirname + "/signup.html") });

app.post("/", function(req, res) { const firstName = (req.body.first_name); const lastName = (req.body.last_name); const email = (req.body.email); const data = { members: [ { email_address: email, status: "subscribed", merge_fields: { FNAME: firstName, LNAME: lastName, }

        }
    ]
};

const jsonData = JSON.stringify(data);
const url = "https://us13.api.mailchimp.com/3.0/lists/e598f4082b";

const options = {
    method: "POST",
    auth: "Pinnacle:c72360e0a9e0b0039a7e9874ce26ee88-us13"
}

const request = https.get(url, options, function(response) {
    response.on(data, function (data) {
        console.log(JSON.parse(data));
    })
});
console.log(request)

request.write(jsonData); 
request.end();

})

app.listen(3000, function() { console.log("server is running on port 3000"); })

I ran this code and I got the error "throw er; // Unhandled 'error' event " on my hyper is terminal

Tobi-Babalola123 commented 1 year ago

errr

Tobi-Babalola123 commented 1 year ago

i've been stuck on this code for 2 days now 😥😥😪