How can I do a request during build-time to retrie...
# kobweb
a
How can I do a request during build-time to retrieve data and show it into my composables ?
n
build-time?
a
I mean not during the website is running but during the website is exporting
this might be useful. don't know of any built-in functionality for this
a
This isn't exactly what I want. I want to download some data online from a precise link known before compiling, currently I'm using the
fetch()
API from DOM, but I want to do this during compiling, not when going on the website.
s
you can just use the java http client in the gradle task
a
Aaah, okay, good to know ! So I should download the JSON at compile time, write down a file containing a string containing the entire JSON, then decode it using Kotlinx.Serialization ? Or do you have any better solution maybe ? 🤔 The syntax of the JSON is defined by myself on another repo so I can do whatever I want with it and I know what will be the syntax
s
apparently you can use kotlinx.serialisation directly in the gradle task by extending the JavaExec task, but I haven't tried this. otherwise, yes, storing a json file and parsing it in the application code should work