@zodic/shared 0.0.135 → 0.0.137
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -42,8 +42,13 @@ export const makeAstrologyApiCall = async (
|
|
|
42
42
|
language: 'en-us' | 'pt-br'
|
|
43
43
|
) => {
|
|
44
44
|
const shortLanguage = language.slice(0, 2);
|
|
45
|
+
|
|
46
|
+
// ✅ Encode Authentication Header using `btoa()`
|
|
47
|
+
const authString = `${env.ASTROLOGY_WESTERN_USER_ID}:${env.ASTROLOGY_WESTERN_API_KEY}`;
|
|
48
|
+
const authHeader = `Basic ${btoa(authString)}`;
|
|
49
|
+
|
|
45
50
|
try {
|
|
46
|
-
const url = `https://astrologyapi.com/
|
|
51
|
+
const url = `https://json.astrologyapi.com/v1/${path}`;
|
|
47
52
|
console.log(`🌍 Making Astrology API Call: ${url}`);
|
|
48
53
|
|
|
49
54
|
const response = await fetch(url, {
|
|
@@ -51,15 +56,13 @@ export const makeAstrologyApiCall = async (
|
|
|
51
56
|
headers: {
|
|
52
57
|
'Content-Type': 'application/json',
|
|
53
58
|
'Accept-Language': shortLanguage,
|
|
54
|
-
Authorization:
|
|
59
|
+
Authorization: authHeader, // ✅ Correct authentication header
|
|
55
60
|
},
|
|
56
61
|
body: JSON.stringify(payload),
|
|
57
62
|
});
|
|
58
63
|
|
|
59
|
-
// ✅ Log response status
|
|
60
64
|
console.log(`🔄 Response Status (${path}):`, response.status);
|
|
61
65
|
|
|
62
|
-
// ✅ Handle non-OK responses gracefully
|
|
63
66
|
if (!response.ok) {
|
|
64
67
|
console.error(
|
|
65
68
|
`❌ API Error (${path}):`,
|
|
@@ -69,14 +72,12 @@ export const makeAstrologyApiCall = async (
|
|
|
69
72
|
throw new Error(`Failed to fetch astrology data from ${path}`);
|
|
70
73
|
}
|
|
71
74
|
|
|
72
|
-
// ✅ Check if response body is empty
|
|
73
75
|
const text = await response.text();
|
|
74
76
|
if (!text) {
|
|
75
77
|
console.error(`❌ API Response Empty (${path})`);
|
|
76
78
|
throw new Error(`Empty response from ${path}`);
|
|
77
79
|
}
|
|
78
80
|
|
|
79
|
-
// ✅ Try parsing JSON
|
|
80
81
|
try {
|
|
81
82
|
return JSON.parse(text);
|
|
82
83
|
} catch (jsonError) {
|