editor-js/link

Endpoint async functions instead of URL

ngmiduc opened this issue ยท 6 comments

Hi,

is it also possible to put an async function as the endpoint instead of haveing a URL ?

I think not. It has to do with CORS, cross site scriptiong. the browser does not let you access one site from another, unless the other explicitely allows it.

Having said that, what confuses me is how it accesses the image. With the fetchUrl argument, I return the image url, somehow it grabs that, but it is not allowed to do so in general. I guess I will be reading the code in greater depth, to see what magic they do, and maybe to make some upgrades.

Thanks for the brilliant work, guys in St. Petersburg (and elsewhere).

@PythonLinks you missed the point that @ngmiduc is trying to make. Actually, he wants to manage making request on his own. Similar to Image plugin.
Currently, I am facing an issue where I have my auth token stored in cookies. Which automatically gets sent to the backend with every request that I make using Axios.
Since cookies are protected by HTTP: only I can't access them with javascript and set it on headers.

This is really needed

Format could be like this

LinkTool : {
    class : LinkTool,
    config : {
        endpointAsync  = (url) => {
               return // some function that somes something with url
        }
    }
}

@PythonLinks you missed the point that @ngmiduc is trying to make. Actually, he wants to manage making request on his own. Similar to Image plugin. Currently, I am facing an issue where I have my auth token stored in cookies. Which automatically gets sent to the backend with every request that I make using Axios. Since cookies are protected by HTTP: only I can't access them with javascript and set it on headers.

Yes sorry for the unclear issue. Yes, I wanted to manage the request by my own.

This is really needed

Format could be like this

LinkTool : {
    class : LinkTool,
    config : {
        endpointAsync  = (url) => {
               return // some function that somes something with url
        }
    }
}

i have the same issue , this would be great if we just get the url do whatever we want with it