Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
Tobi-Babalola123 opened this issue Nov 2, 2023 · 2 comments
Open

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

Tobi-Babalola123 opened this issue Nov 2, 2023 · 2 comments

Comments

@Tobi-Babalola123
Copy link

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
Copy link
Author

errr

@Tobi-Babalola123
Copy link
Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant