forked from MihirMandviya/message-blast-easy
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-delete-template.js
More file actions
54 lines (48 loc) · 1.52 KB
/
Copy pathtest-delete-template.js
File metadata and controls
54 lines (48 loc) · 1.52 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
// Test script to debug delete template API
const testDeleteTemplate = async () => {
const testData = {
userId: 'nandlalwa',
password: 'your_password_here', // Replace with actual password
wabaNumber: '919370853371',
templateName: 'test_template_name', // Replace with actual template name
language: 'en'
};
console.log('Testing delete template API with data:', {
...testData,
password: '***' + testData.password.slice(-4)
});
try {
// Test the proxy endpoint (port 8080)
const response = await fetch('http://localhost:8080/api/delete-template', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(testData)
});
console.log('Response status:', response.status);
console.log('Response headers:', Object.fromEntries(response.headers.entries()));
const responseText = await response.text();
console.log('Response text:', responseText);
if (response.ok) {
try {
const data = JSON.parse(responseText);
console.log('Parsed response:', data);
} catch (e) {
console.log('Response is not JSON');
}
} else {
console.log('Request failed with status:', response.status);
try {
const errorData = JSON.parse(responseText);
console.log('Error details:', errorData);
} catch (e) {
console.log('Error response is not JSON');
}
}
} catch (error) {
console.error('Error:', error);
}
};
// Run the test
testDeleteTemplate();