#How to get the path of BaseDirectory.App in Vuex store?

2 messages · Page 1 of 1 (latest)

hollow harness
#

I want to import my config.json file directly into the vuex store and use it dynamically if it changes without using all the time readTextFile as a mutation call.

Like this for example:

import { writeTextFile, BaseDirectory } from "@tauri-apps/api/fs";
import configpath from `$(BaseDirectory.App)/config.json`

export default {
  state: {
    path: configpath,
  },
}

// or alternative

export default {
  state: {
    path: `$(BaseDirectory.App)/config.json`,
  },
}

But BaseDirectory.App returns 18 instead of a file path. How I can extract the file path out of it or is there a better option? 😅

arctic pawn
#

But BaseDirectory.App returns 18 instead of a file path. How I can extract the file path out of it or is there a better option? 😅
You can't excrat the path out of the BaseDir enum, but there is an api to get the actual path https://tauri.app/v1/api/js/path/#appdir