-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
49 lines (40 loc) · 1.3 KB
/
app.js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
function onGeoOk() {
const url = `https://port-0-tofaker-backend-lzsaeexf05f2c47e.sel4.cloudtype.app/api/v1/feed/random`;
fetch(url).then(response => response.json())
.then(data => {
console.log(data)
/*const idNumber = document.getElementById("id");
const contents = document.getElementById("content");
idNumber.innerText = data.id;
contents.innerText = data.title;
console.log(data.pictureUrl);
const Img = document.getElementById("emoji");
Img.onload = function() {
Img.width =Img.naturalWidth / 8;
Img.height =Img.naturalHeight / 8;
};
Img.src = data.pictureUrl;
*/
});
}
onGeoOk();
function submitForm() {
const form = document.getElementById('myForm');
console.log(form)
const formData = new FormData(form);
const url = 'https://port-0-tofaker-backend-lzsaeexf05f2c47e.sel4.cloudtype.app/api/v1/feed'; // API의 URL로 변경하세요.
for (const [key, value] of formData.entries()) {
console.log(`${key}: ${value}`);
}
fetch(url, {
method: 'POST',
body: formData
})
.then(response => response.json())
.then(data => {
console.log('Success:', data);
})
.catch((error) => {
console.error('Error:', error);
});
}