git clone [email protected]:s2xon/userauth.git cd email-password-handler
Obtain the necessary environment variables/.env from your PlanetScale account for connecting to the "data" database.
go mod tidy
go run server/main.go
Navigate to the project directory in your terminal.
Make a POST request to the root ("/") of the server with a JSON body containing an "Email" and "Password."
You can use the following example code within a JavaScript file (e.g., main.js
):
document.querySelector("button").addEventListener("click", (e) => {
e.preventDefault();
fetch(url, {
method: 'POST',
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: Email,
password: Password,
}),
})
.then((response) => console.log(response.json()));
});
If you want to delve deeper into the technologies used in this project, explore the following resources:
- The Go Programming Language: https://go.dev/
- net/http package documentation: https://pkg.go.dev/net/http
- encoding/json package documentation: https://pkg.go.dev/encoding/json