Best way to Read JSON files (Locally Stored)
Hello all,
Just picked up Solid for the first time today after learning a little react.
1) Where is the best place to get the most up to date documentation? The SolidJS website is a little light on specific syntax and such compared to other languages and frameworks.
2) I have a locally stored JSON file which I want to read from (Displaying names, descriptions and pictures of items for e-commerce store.) What is the best way to get that info?
Any help would be highly appreciated ESPECIALLY pointing me in the direction of the more detailed documentation.
All the best
11 Replies
For #2, if you’re using typescript or Vite, you can import the JSON file directly with
import someName from “somePath/someFile.json”
Thanks for responding.
I do have a vite.config.js file as part of my project so I am assuming vite is active but your suggestion is the first thing I tried and I could not get it working.
there is an option for resolving json in tsconfig
I am not using type script unfortunately 😦
https://www.youtube.com/watch?v=ZZ-a7B761Ds&t=123s @59.50 they managed to do an API call of some JSON. I tried to copy it but a bunch of errors come up
Learn With Jason
YouTube
Let's Learn SolidJS
SolidJS is an exciting framework with a small (6.4kb) footprint, a reactive, component-based approach, and incredible performance. In this episode, Ryan Carniato will teach us how to get started with our first SolidJS app!
00:00:00 Welcome
00:00:24 Guest introduction
00:02:46 Jason's initial thoughts on SolidJS
00:04:21 What's different about S...
This one is from the vid
same question here. It seems this question has never been answered. @twisteddisco Do you have a proper solution now?
vite supports it naively though: https://vitejs.dev/guide/features.html#json
Vite
Next Generation Frontend Tooling
Hey, yeah i eventually went with a vanilla JS approach but will have another look at some point 🙂