-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaScript
More file actions
18 lines (17 loc) · 682 Bytes
/
JavaScript
File metadata and controls
18 lines (17 loc) · 682 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
async function fetchData() {
try {
const response = await fetch('https://your-fastapi-server.com/process-nlp/', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer YvZz9Hni0hWJPh_UWW4dQYf9rhIe9nNYcC5ZQTTZz0Q' // Replace with your actual secure token
},
body: JSON.stringify({ text: "Hello FastAPI" })
});
const data = await response.json();
document.getElementById('response').innerText = data.response;
} catch (error) {
document.getElementById('response').innerText = 'Error fetching data';
}
}
fetchData();