SolidJSS
SolidJSโ€ข3y agoโ€ข
7 replies
Mathieu

fetch in createEffect?

When a set of conditions are satisfied on some state, I want to execute an http request to the server. I'd have something like:
createEffect(() => {
  if (state() && anotherState()) {
    andAnotherState();
    // execute http request
    andYetAnotherState();
  }
});

Is it okay to initiate http request from createEffect? Is there anything to be aware of? I guess I don't need to use async/await? (i.e. I don't need to write createEffect(async () => // ...) as the synchronous execution shouldn't be paused?)
Was this page helpful?