Alexnm Shows the terribly disgusting architecture you must provide to simply have a server wait before an API call is complete before a server responds to a client.
He shows that you must first document each component of your entire app in a single, non-hierarchical flat list, then filter through every single component to see if a component has a API "data-requirement" for every single request, then store the output of that API request in a global redux object (also disgusting), then somehow pass that back to the object in the hopes it doesn't collide with other requests.
This is because ReactJS "lifecycle" hooks aren't actually lifecycle hooks at all, and is instead "fast and free" (and fun).
I don't really care for any of these libraries, ES[xyz] syntaxes, and strange philosophies, but what I would like to do is return the an http response after and API call is made, i.e.
render() {
// do an API call.
// return a response.
}
I've seen uses if fetch(xyz).then(() => {})
and so many other colorful brackets and functions where I'm not totally sure where parameters go in or where they go out, and I can't seem to figure out how to simply hold off the next line of code before the previous line of code is complete. In then(() => {})
, which is syntaticly beautiful, I'm unable to return a value in any way at all. It's called a function, but I'm having difficulty achieving anything other than a side side-effect, and am unable to return a result of any kind.
Does anyone know how to make the render()
, on it's own, wait for an API call?