datastar
datastar copied to clipboard
Cannot set properties of undefined error when attempting to use Custom Header
I was trying to see what custom headers looked like in action, and ran into this issue. My component block triggering the problem looks like the following:
<div
id="root"
class="flex flex-row h-screen max-w-full"
data-on-load="$$get('/endpoint')"
data-header-X-My-Header="myheader"
data-store={ templ.JSONString(store) }
></div>
I believe I am not doing anything explicitly incorrectly based off of the docs
I traced the issue to the following lines: https://github.com/delaneyj/datastar/blob/5c0865d4a6a54a7162ef77d229092888b9d2fe66/packages/library/src/lib/plugins/backend.ts#L53-L55
the destructured headers variable is the main culprit. After trying a quick fix of adding _value to see what would happen next, I got an Error evaluating Datastar expression error message that seems to indicate my custom header is being evaluated as a variable