forked from bluesky-social/statusphere-example-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Axios form
Ray edited this page Jan 18, 2025
·
1 revision
import axios from 'axios';
const handleSubmit = async (event) => {
event.preventDefault();
const form = event.target;
const formData = new FormData(form);
try {
const response = await axios.post('/your-api-endpoint', formData);
console.log('Form submitted successfully:', response.data);
} catch (error) {
console.error('Error submitting form:', error);
}
};
const form = document.getElementById('my-form');
form.addEventListener('submit', handleSubmit);