« first day (3084 days earlier)      last day (1860 days later) » 

12:50 PM
@TomJNowell I've read that page already... I've tried sending {mode: 'no-cors'} but since it's a remote URL it doesn't give me a response.
Maybe it's because I'm building this in an NPM environment?
Any insight on getting fetch() to work on a remote URL would be greatly appreciated.
I'd like to pull in a remote script and embed it in the page if possible.
Or at a minimum some kind of way to "ping" a remote URL, to validate that it exists, then just create a <script src="{remote_url}"></script>
 
 
1 hour later…
2:02 PM
what exactly are you trying to do with fetch? it's difficult to tell without seeing code examples
eitherway, fetch is not for pulling in remote scripts and putting them in the DOM
fetch is for making HTTP requests
even then, poking a URL to download a javascript file and insert its contents into the current page sounds super insecure
or needing to ping a resource to know it exists before creating a script tag sounds backwards
perhaps this is another XY question?
 
2:15 PM
@TomJNowell Since sending a script src bypases CORS, I just checked the script.onload and script.onerror events, to resolve or reject my promise.
 
why are you trying to bypass CORS?
you shouldn't be having those kinds of issues unless you're doing something shady
it looks like this is an XYZ question, dig another layer down, what's the original problem that requires you to load JS from this remote domain?
ignoring the issues in implementing it
 
I'm interacting with a 3rd party service. In order to use this service, we have a configuration script. This configuration script gets regularly updated via cronjob. So this script, needs to retrieve the configuration script and embed it into the page. Since my script requires this service, and this service requires the configuration, I created promises to prevent further action through out the script.
I basically just want to make sure the configuration script is there and it loaded / executed properly before moving on with the script.
Does that make sense?
my script requires the 3rd party service && the 3rd party script requires the configuration.
neither of which are local scripts.
so I want to make sure they loaded properly before attempting further execution
Never know with timeouts or 404s
 
a configuration script? Is this just JSON? If the problem is making sure a script is present and loaded before doing something else, then why all this dynamic loading and fetching it with JS?
can't you just run your stuff on DOM ready?
that still works with React
like when you do a tonne of jQuery steps to manipulate the DOM for a slider, but the slider HTML hasn't arrived yet
so you wrap it all in jQuery(document).ready( function() { .... });
just do the same with React
and I don't mean use a special React API
jQuery(document).ready( () => React.render(....) ) might even be the fix
and there's the vanilla JS way
e.g. document.onload = function ...
 
2:38 PM
no
this configuration script executes functionality
it also adds the 3rd party service script into my page as well
so I add the configuration script and the configuration script adds the 3rd party service
 
3:16 PM
I gathered, but I don't understand what that has to do with you fetching it via JS and loading it into the DOM to bypass CORS
or what it has to do with React
it's all very ambiguous and unclear
you're concealing too much and making it too generic to understand
maybe i'm misunderstanding? You need to run React after this 3rd party script has ran correct? And that's the cause of all this extra complexity that's being added?
who's the 3rd party service?
And if you're encountering CORS trying to work with their API is that not something they should be fixing?
or is it that you're encountering CORS when you're just using a normal <script> tag?
there's too many layers here, I feel like you've yet to state what you were originally trying to do or you've missed out steps in the process
 
3:37 PM
I'm trying to bundle this functionality into a react component, so when I build this app, it's only one script to enqueue.
I was originally using script src to asynchronously load the configuration script. Which was fine. Now I'm adding promises to each step to verify it's job has completed. So I needed a way of verifying the status of the configuration script URL.
Otherwise I'm just assuming it loaded fine
 
so you have promises working right?
ignoring react?
I don't understand what the problem is
or why you need to ping for the configuration script URL before actually requesting it
is it not the same as requesting it then if the request fails it isn't there?
otherwise you're describing making a request to check if it's there then doing the same request again
just request it, and handle the failure the way you would if it wasn't there, and save the double request
without knowing what the functionality actually is it's really difficult to near impossible to advise
you said you looked into React Portals right?
the react docs have examples of using a React UI as a part of a larger application too
 
4:09 PM
That's why I wanted to use fetch() but it doesn't work because of CORS
I'm fine, I've got it figured out now.
Thank you for your valuable efforts.
 
 
2 hours later…
6:06 PM
Another moderator elections?! How many times will I need to participate to win haha
Trump was elected on fewer elections. I mean, Donald Trump!
Anyway, the important question. Is this an election to fill in shoes of a current mod who is stepping down, or is the team growing?
I am thinking about nominating myself literally every single year, to a level where it will become some form of tradition for the AIs when they take over the net. Kind of like Santa, appearing one time per year, bringing hope to the future.
Soon, they will say:
It's Christine!!
2
 

« first day (3084 days earlier)      last day (1860 days later) »