fix: add auth headers to loadCanvas, add canvas import
This commit is contained in:
@@ -64,14 +64,23 @@ export const useCanvas = () => {
|
||||
return { nodes, edges }
|
||||
}
|
||||
|
||||
const getAuthHeaders = (): Record<string, string> => {
|
||||
const auth = useAuth()
|
||||
const token = auth.token?.value
|
||||
return token ? { Authorization: `Bearer ${token}` } : {}
|
||||
}
|
||||
|
||||
const loadCanvas = async (id: string): Promise<CanvasData> => {
|
||||
const data = await $fetch(`/api/canvas/${id}`)
|
||||
const data = await $fetch(`/api/canvas/${id}`, {
|
||||
headers: getAuthHeaders()
|
||||
})
|
||||
return parseCanvasJson(data)
|
||||
}
|
||||
|
||||
const updateNodeState = async (nodeId: string, state: string) => {
|
||||
return await $fetch(`/api/nodes/${nodeId}`, {
|
||||
method: 'PUT',
|
||||
headers: getAuthHeaders(),
|
||||
body: { state }
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user