Skip to content

Commit

Permalink
changes
Browse files Browse the repository at this point in the history
  • Loading branch information
madeline-lei committed Nov 2, 2024
1 parent 849a715 commit de9ec68
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 107 deletions.
100 changes: 0 additions & 100 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
"preview": "vite preview"
},
"dependencies": {
"axios": "^1.7.7",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"wouter": "^3.3.5"
Expand Down
21 changes: 15 additions & 6 deletions src/pages/Contact.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

import { useState } from 'react';
import axios from 'axios';

export default function Contact( ) {

Expand All @@ -20,15 +19,25 @@ export default function Contact( ) {

e.preventDefault();
try {
const response = await axios.post(`${import.meta.env.VITE_API_URL}/api/contact`, formData)
if(response.status == 201) {
alert("Inquiry submitted successfully!")
const response = await fetch("http://localhost:4000/api/contact", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({name, email, subject, message})
})

if(!response.ok) {
throw new Error(`Response status: ${response.status}`);
}
const json = await response.json()
console.log(json)
alert("Inquiry submitted successfully!")

} catch (err) {
console.error(error.message)
alert("There was an error submitting the inquiry.")
}

console.log('Form submitted:', formData);
};


Expand Down

0 comments on commit de9ec68

Please sign in to comment.