Anyone help me in sample request with headers to u...
# questions
s
Anyone help me in sample request with headers to use export api in react. I have tried but getting unauthorized error all the time. Am in missing something here? const API_SECRET = 'api secret'; const API_KEY = 'project token'; const apiUrl = 'https://data.mixpanel.com/api/2.0/export?from_date=2023-11-05&to_date=2023-11-08' fetch(apiUrl, { mode: 'no-cors', headers: { accept: 'application/json', Authorization: `Basic ${btoa(
${API_KEY}:${API_SECRET}
)}`, } }) .then(response => { if (response.ok) { return response.json(); } throw new Error('Network response was not ok.'); }) .then(data => { // Handle the data from the API response console.log('API Response:', data); }) .catch(error => { // Handle errors here console.error('Error:', error); });