TriplyDB / Yasgui

Yet Another Sparql GUI
https://yasgui.triply.cc
MIT License
190 stars 55 forks source link

How to set configurations when object initalized #143

Closed shawnhind closed 4 years ago

shawnhind commented 4 years ago

We're using YASGUI to query our graph database and our query endpoint uses a CSRF token for session validation.

I'm initializing YASGUI doing this:

const yasgui = new Yasgui(document.getElementById("yasgui"), {
                requestConfig: { 
                    endpoint: "{{ route('sparql.query') }}", 
                    headers: {
                        "X-CSRF-TOKEN": someCsrfToken
                    }
                },
                copyEndpointOnNewTab: false  
            });

However after logging out and logging back in and then reloading the page, YASGUI is still sending the original header with the expired CSRF token which I assume it's getting from the cached config in local storage.

How can I modify config values in a way that will override the saved local storage values. Is there a way other than to run code that will clear the local storage object?

LaurensRietveld commented 4 years ago

I've changed the request configuration setup somewhat.

Something like this should work now (when using the latest release):

const yasgui = new Yasgui(document.getElementById("yasgui"), {
                requestConfig: { 
                    endpoint: "{{ route('sparql.query') }}", 
                    headers: () => ({
                        "X-CSRF-TOKEN": someCsrfToken
                    })
                },
                copyEndpointOnNewTab: false  
            });
shawnhind commented 4 years ago

Great, thanks. I'll give this a try later today.

shawnhind commented 4 years ago

@LaurensRietveld this worked perfectly, thanks.

LaurensRietveld commented 4 years ago

Great :+1: