summaryrefslogtreecommitdiff
path: root/frontend/src/Options.js
blob: 4c8a7e9580a9fce7c489f30900330bad92392c92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import React, { useState } from 'react';
import './Options.css';

const Options = () => {
  const [message, setMessage] = useState('');

  const handleClick = async () => {
    setMessage('Sending request...');
    try {
      const response = await fetch('http://localhost:8000/create_route', { method: 'POST' });
      const data = await response.json();
      setMessage(`Response received: ${JSON.stringify(data)}`);
    } catch (error) {
      setMessage(`Error: ${error}`);
    }
  };

  return (
    <div className="p-8">
      <button 
        className="options-button"
        onClick={handleClick}
      >
        Create Route
      </button>
      <p className='text-white pt-2'>{message}</p>
    </div>
  );
}

export default Options;