Hi I’m trying to make a login thing in html and I’m trying to make it so basically you type your email in the box and then it emails you a code that you have to type to login, basically like glitch’s “magic email” login. I got the email system set up and here is what I’m trying to do. In my website the script does a http POST and the node.js app receives a JSON file so it can email someone. Then the node.js app can returns the code. I just need help on sending the JSON file and returning a 6 digit code. Please help!
Do you have some code we can work on, for the JSON sending part?
Uhhh, what about the POST request part?
I haven’t added that yet and that’s the part I need help on
Sorry for asking so many questions, but do you have the code that does this?
No I don’t have the code for that yet.
Now’s a good a time to start on that as any! Here’s a guide on how to POST a JSON file Using Fetch - Web APIs | MDN
I did that on my website but how do I set it to receive on my node.js app?
what framework are you using on the server side? express?
Yeah on node.js
Thanks but is it possible to send the JSON file from a glitch-hello-website to a node.js app?
yup, you can use nodejs’s http or https module. or if you already have code what works with
fetch in a browser, you can get the node-fetch package from npm to run it on the server
I’ve been trying to understand how to do it on that website you linked but I still don’t know.
uh-oh, I hadn’t linked to the websites about the latest understanding of what you’re trying to do! but here’s a link for that right now: node-fetch - npm
maybe see if you can get that snippet working in isolation and then integrate it into your node.js project.
also, to clarify: this is less “send from the static site” and more “request from the node.js app”