How to make fetch requests before rendering #1107
-
I have a golang server, My app is written in solidjs, Solidjs App when renders makes requests to server from user's browser to the server and then creates components, This approach is good But I would like to do is make a request to fetch the resource when rendering, right from the server and deliver straight HTML to the browser, How to do this ? This means rendering must be stopped and wait until that fetch request has completed |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
I would like to setup a server on the port 8080 and another Golang / Rust server on port 3000 The NodeJS server would make requests to Golang server to retrieve resources and serve them in HTML, This would also mean bots would be able to crawl my dynamic site @ryan How to do this ? async function Checkout() {
let res : string;
await fetch("http://example.com").then((e) => e.text()).then(e => {
console.log("LOOK : " + e)
res = e;
})
return (
<>
<Show when={res != null}>
<div innerHTML={res} />
</Show>
<Show when={res == null}>
Internal Server Error : Resource Missing
</Show>
</>
)
} |
Beta Was this translation helpful? Give feedback.
https://start.solidjs.com/api/createServerData