NPM Package functionality on form submit - front end

Viewed 29

So I am experimenting with NPM. I could not get it working in my own at school, but want to try again during the holidays.

Here is the backend I am working with:

module.exports = index.js

Basically goal is to have a user search domain on my search bar and return the results from functionality.

I know I need a script tag after my form on the front end, but unsure what this would look like. Any advice or direction for my own knowledge would be appreciated Happy Holidays.

1 Answers

why you export like this module.exports = index.js, you have to export Function or Object or ... that exist in the file and needed , for exampe module.exports = app

after that when you want to create a web server with node (express) you should implement and run the server on a specific port like this


const PORT = 3000

app.listen(PORT, () => {
  console.log(`Example app listening at http://localhost:${PORT}`)
})


In this snippet, we listen to the server on 3000 port

Related