Kochani.
W poprzednim wątku https://4programmers.net/Forum/Webmastering/376161-uzywanie_hurtowni_danych_ceidg?p=1998470#id1998470
udało mi się pobrać dane za pomocą curl. Chciałem powtórzyć to przy pomocy node.js ale zwraca mi błąd 401
const apiKey = 'secretsecretsecret'
const govUrl = 'https://dane.biznes.gov.pl/api/ceidg/v2/firmy?nip=8821549180'
const autorization = `Bearer ${apiKey}`;
async function getCompany() {
const url = govUrl;
try {
const response = await fetch(url, {
method: 'GET',
headers: {
"Autorization": autorization,
"Content-Type": "application/json"
}
});
if (!response.ok) {
throw new Error(`Response status: ${response.status}`);
}
const json = await response.json();
console.log(json);
} catch (error) {
console.error(error.message);
}
}
await getCompany()
Czy wiecie co robię nie tak?