Skip to content
This repository was archived by the owner on Feb 21, 2025. It is now read-only.

Commit 715534e

Browse files
committed
Merge remote-tracking branch 'origin/employer_fetch_names'
2 parents 44565c1 + 4e53615 commit 715534e

File tree

1 file changed

+40
-3
lines changed

1 file changed

+40
-3
lines changed

src/pages/employers/EmployersDashboard.tsx

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,46 @@ const getUniqueOptions = (data: string[]) => Array.from(new Set(data));
1212
const API_URL = import.meta.env.VITE_API_URL;
1313
console.log('Backend API:', API_URL);
1414

15-
fetch(`${API_URL}n/s/Alex`)
16-
.then((response) => response.json())
17-
.then((data) => console.log(data));
15+
// fetch(`${API_URL}/v`)
16+
// .then((response) => response.json())
17+
// .then((data) => console.log(data));
18+
19+
// POST request to create a new entry
20+
async function postThenFetch() {
21+
try {
22+
// POST operation
23+
const postResponse = await fetch(`${API_URL}/newEntry`, {
24+
method: 'POST',
25+
headers: {
26+
'Content-Type': 'application/json',
27+
},
28+
body: JSON.stringify({
29+
subject: 'Pacorro',
30+
verb: 'loves',
31+
object: 'apples',
32+
isPublic: true,
33+
statement: 'Paco loves apples',
34+
}),
35+
});
36+
if (!postResponse.ok) {
37+
throw new Error(`HTTP error on POST! status: ${postResponse.status}`);
38+
}
39+
const postData = await postResponse.json();
40+
console.log('Successfully posted:', postData);
41+
42+
// GET operation after POST completes
43+
const getResponse = await fetch(`${API_URL}/n/s/Pacorro`);
44+
if (!getResponse.ok) {
45+
throw new Error(`HTTP error on GET! status: ${getResponse.status}`);
46+
}
47+
const getData = await getResponse.json();
48+
console.log(`Fetching from DV: ${JSON.stringify(getData, null, 2)}`);
49+
} catch (error) {
50+
console.error('Error with requests:', error);
51+
}
52+
}
53+
54+
postThenFetch();
1855

1956
const EmployersDashboard: React.FC = () => {
2057
const [filters, setFilters] = useState({

0 commit comments

Comments
 (0)