I’m trying to use Templater to write data to a file in an obsidian vault.
I can APPEND to an existing file just fine:
let strOut = “string to append to file”
const file = tp.file.find_tfile(fileName)
await app.vault.adapter.append(file.path, strOut)
But I don’t want to append, I want to overwrite. So I need modify (or even delete and create)
but changing the last line of the above from .append to .modify:
await app.vault.adapter.modify(file.path, strOut)
results in the error: “app.vault.adapter.modify is not a function”
await app.vault.modify(file.path, indexOut)
results in the error: "Cannot create property ‘saving’ on string ‘testfile.md’ "
trying to combine delete and append throws no error:
await app.vault.delete(indexfile.path)
await app.vault.adapter.append(indexfile.path, indexOut)
but it also doesn’t actually delete the file.
I know I’m just doing something stupid. If anyone can give me an example of the proper way to call modify I would be extremely grateful.