-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
36 lines (29 loc) · 794 Bytes
/
test.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
const fetch = require('node-fetch');
const API_ENDPOINT = 'http://localhost:3000/api/v1/bots/create';
const botDetails = {
botName: 'TestingBot#0000',
clientId: '',
botToken: '',
botSecret: '',
userId: '',
};
async function createBot() {
try {
const response = await fetch(API_ENDPOINT, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(botDetails),
});
const data = await response.json();
if (response.ok) {
console.log('Bot created successfully:', data.message);
} else {
console.log('Error creating bot:', data.message);
}
} catch (error) {
console.error('Error sending POST request:', error.message);
}
}
createBot();