Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How do I store a fetch response to a derived store in svelte?

I have a list of items which I consume from an own custom built API (in the example I’ll use typicode) and want to display them. Additionally I want to add a client side search functionality. It is exactly like this REPL from this question.

But the given list is hardcoded, yet I can’t seem to build a fetch call to get those items prior and afterwards display them. Only then can the user search and filter them.

Here is my REPL.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

response.json() returns a promise, so you should await it.

Working example: https://svelte.dev/repl/a93ac2dcff584b2f8d11e430c6a96fa9?version=3.31.2

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading