-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbulkEmails.js
More file actions
107 lines (97 loc) · 3.02 KB
/
Copy pathbulkEmails.js
File metadata and controls
107 lines (97 loc) · 3.02 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
const testData = [{
Categories : "Participants",
"Company/Organization" : null,
Date : null,
Email : "imubarak2424@gmail.com",
"First Name" : "JUNAIDU",
"Institutional Affiliation" : null,
"Last Name" : "SALISU",
"Phone Number" : null
}, {
Categories : "Participants",
"Company/Organization" : null,
Date : null,
Email : "m.bthedon@yahoo.com",
"First Name" : "JUNAIDU",
"Institutional Affiliation" : null,
"Last Name" : "SALISU",
"Phone Number" : null
}, {
Categories : "Participants",
"Company/Organization" : null,
Date : null,
Email : "shithappens242@gmail.com",
"First Name" : "JUNAIDU",
"Institutional Affiliation" : null,
"Last Name" : "SALISU",
"Phone Number" : null
}];
// fetch('http://localhost:3000/api/v1/emails', {
// method: 'POST',
// mode: 'no-cors',
// headers: {
// 'Content-Type': 'application/json',
// },
// body: JSON.stringify({
// "email" : testData[0].Email,
// "name" : `${testData[0]["Last Name"]} ${testData[0]["First Name"]}`,
// "category" : testData[0].Categories
// }),
// })
// .then((response) => response.json())
// .then((data) => {
// console.log('success: ', data);
// })
// async function postData(url = '', data = {}) {
// // Default options are marked with *
// const response = await fetch(url, {
// method: 'POST',
// mode: 'no-cors',
// cache: 'no-cache',
// credentials: 'same-origin',
// headers: {
// 'Content-Type': 'application/json',
// },
// body: JSON.stringify(data) // body data type must match "Content-Type" header
// });
// return response.text();// parses JSON response into native JavaScript objects
// }
// postData('http://localhost:3000/api/v1/emails', {
// "email" : testData[0].Email,
// "name" : `${testData[0]["Last Name"]} ${testData[0]["First Name"]}`,
// "category" : testData[0].Categories
// })
// .then((data) => {
// console.log(JSON.parse(data));
// });
const looper = async (data) => {
for(let x = 733; x < data.length; x++){
await fetch('http://localhost:3000/api/v1/emails', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
"email" : data[x].Email,
"name" : `${data[x]["Last Name"]} ${data[x]["First Name"]}`,
"category" : data[x].Categories
}),
})
.then((response) => response.json())
.then((data) => {
console.log(x)
console.log('success: ', data);
})
.catch((error) => {
console.error('Error: ', error);
});
}
};
//looper(testData);
// console.log("Its working at this put")
// fetch('https://sheet.best/api/sheets/7d520258-c5f2-4cc6-8644-436ff5e3e6c5')
// .then((res) => (res.json()))
// .then((data) => {
// console.log(data)
// looper(data);
// })