Hi,
I get data in json format from an API endpoint. I need to store this data in a file in my solid pod. I got the information that solid-client library serves this purpose. Can I know how it can be used to save the data in my pod?
Thanks…
This is the relevant documentation to store data in arbitrary formats (like JSON) on a Pod: Read/Write Files (Non-RDF Resources) — Inrupt JavaScript Client Libraries
1 Like
Smag0
May 25, 2023, 10:36pm
3
An example in a vuejs plugin
let store = opts.store
// console.log(store)
Vue.prototype.$createRemote = async function(n){
console.log(store.state.solid.pod)
console.log(store.state.solid.pod.neuroneStore, n)
n['ve:url'] = store.state.solid.pod.neuroneStore+n.id
n['ve:synchronized'] = Date.now()
try{
const savedFile = await overwriteFile(
n['ve:url'],
new Blob([JSON.stringify(n, undefined, 2)], { type: "application/json" }),
{ contentType: "application/json", fetch: sc.fetch }
// new Blob([JSON.stringify(n, undefined, 2)], { type: "application/ld+json" }),
// { contentType: "application/ld+json", fetch: sc.fetch }
);
console.log(`File saved at ${getSourceUrl(savedFile)}`);
//n.url = await getSourceUrl(savedFile)
// store.dispatch('nodes/saveNode', n)
return n