Spaces:
Sleeping
Sleeping
Update frontend/src/services/api.js
Browse files- frontend/src/services/api.js +27 -0
frontend/src/services/api.js
CHANGED
|
@@ -80,6 +80,33 @@ export async function getExtractionById(extractionId) {
|
|
| 80 |
return await response.json();
|
| 81 |
}
|
| 82 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 83 |
/**
|
| 84 |
* Share an extraction with another user(s)
|
| 85 |
* @param {number} extractionId - The extraction ID to share
|
|
|
|
| 80 |
return await response.json();
|
| 81 |
}
|
| 82 |
|
| 83 |
+
/**
|
| 84 |
+
* Create a shareable link for an extraction
|
| 85 |
+
* @param {number} extractionId - The extraction ID to share
|
| 86 |
+
* @returns {Promise<Object>} Share link result with share_link
|
| 87 |
+
*/
|
| 88 |
+
export async function createShareLink(extractionId) {
|
| 89 |
+
const response = await fetch(`${API_BASE_URL}/api/share/link`, {
|
| 90 |
+
method: "POST",
|
| 91 |
+
headers: {
|
| 92 |
+
"Content-Type": "application/json",
|
| 93 |
+
...getAuthHeaders(),
|
| 94 |
+
},
|
| 95 |
+
body: JSON.stringify({
|
| 96 |
+
extraction_id: extractionId,
|
| 97 |
+
}),
|
| 98 |
+
});
|
| 99 |
+
|
| 100 |
+
if (!response.ok) {
|
| 101 |
+
const errorData = await response.json().catch(() => ({
|
| 102 |
+
error: `HTTP ${response.status}: ${response.statusText}`,
|
| 103 |
+
}));
|
| 104 |
+
throw new Error(errorData.error || errorData.detail || "Failed to create share link");
|
| 105 |
+
}
|
| 106 |
+
|
| 107 |
+
return await response.json();
|
| 108 |
+
}
|
| 109 |
+
|
| 110 |
/**
|
| 111 |
* Share an extraction with another user(s)
|
| 112 |
* @param {number} extractionId - The extraction ID to share
|