App.vault.modify

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.

You’re using wrong function name or wrong parameter type.
There is no such function as app.vault.adapter.modify, and the vault methods (app.vault.xxx) expects TFile instead of a string path.

Just take a look at the Obsidian API docs, it has comprehensive list of available methods and corresponding parameter types:

Use Vault if possible. (The only scenarios where you should use adapter that I can come up with are when dealing with hidden files, files in hidden folders such as .obsidian)

Thanks, I’ll try this!

Thank you for your help Ush.
I was absolutely using the wrong parameter type.
app.vault.modify works just fine when I pass in a TFile instead of a path. Duh. I knew I was doing something stupid.