fix: add auth token to all API calls (prompts, insights, pipeline)
This commit is contained in:
1 parent
89b6c0b072
commit
5091dfd1ce
5 files changed
+9
-19
No files matched your search
@@ -117,7 +117,7 @@ export default function Analysis() {
|
||||
|
||||
const loadAll = async () => {
|
||||
const [p, i] = await Promise.all([
|
||||
fetch('/api/prompts').then(r=>r.json()),
|
||||
api.listPrompts(),
|
||||
api.listInsights()
|
||||
])
|
||||
setPrompts(Array.isArray(p)?p:[])
|
||||
@@ -128,12 +128,7 @@ export default function Analysis() {
|
||||
const runPipeline = async () => {
|
||||
setPipelineLoading(true); setError(null); setNewResult(null)
|
||||
try {
|
||||
const pid = localStorage.getItem('bodytrack_active_profile')||''
|
||||
const r = await fetch('/api/insights/pipeline', {
|
||||
method:'POST', headers: pid ? {'X-Profile-Id':pid} : {}
|
||||
})
|
||||
if (!r.ok) throw new Error(await r.text())
|
||||
const result = await r.json()
|
||||
const result = await api.insightPipeline()
|
||||
setNewResult(result)
|
||||
await loadAll()
|
||||
setTab('run')
|
||||
@@ -145,12 +140,7 @@ export default function Analysis() {
|
||||
const runPrompt = async (slug) => {
|
||||
setLoading(slug); setError(null); setNewResult(null)
|
||||
try {
|
||||
const pid = localStorage.getItem('bodytrack_active_profile')||''
|
||||
const r = await fetch(`/api/insights/run/${slug}`, {
|
||||
method:'POST', headers: pid ? {'X-Profile-Id':pid} : {}
|
||||
})
|
||||
if (!r.ok) throw new Error(await r.text())
|
||||
const result = await r.json()
|
||||
const result = await api.runInsight(slug)
|
||||
setNewResult(result) // show immediately
|
||||
await loadAll() // refresh lists
|
||||
setTab('run') // stay on run tab to see result
|
||||
|
||||
Reference in new issue
Block a user