-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-api.js
More file actions
39 lines (33 loc) · 1.38 KB
/
test-api.js
File metadata and controls
39 lines (33 loc) · 1.38 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
import fetch from 'node-fetch';
// ==========================================
// COLOQUE SUA CHAVE API AQUI PARA TESTAR
const API_KEY = "YOUR_API_KEY_HERE";
// ==========================================
async function testApi() {
console.log("Iniciando teste de API Limitless...");
console.log(`Usando chave: ${API_KEY.substring(0, 10)}...`);
const today = new Date();
const start = new Date(today);
start.setDate(today.getDate() - 1);
const url = `https://api.limitless.ai/v1/lifelogs?start=${start.toISOString()}&end=${today.toISOString()}`;
try {
// 1. Tentativa A: Authorization Bearer
console.log("\n--- Tentativa A: Authorization: Bearer ---");
const headersA = {
'Authorization': `Bearer ${API_KEY.trim()}`,
'Accept': 'application/json'
};
const responseA = await fetch(url, { headers: headersA });
console.log(`Status A: ${responseA.status} ${responseA.statusText}`);
if (responseA.status === 200) {
console.log("✅ SUCESSO com Bearer!");
} else {
console.log(`Body A: ${(await responseA.text()).substring(0, 200)}`);
}
// 2. Tentativa B: X-API-Key
console.log("\n--- Tentativa B: X-API-Key ---");
const headersB = {
'X-API-Key': API_KEY.trim(),
'Accept': 'application/json'
};
testApi();