* Fetches a single note as structured JSON with content, frontmatter, stats, and tags.
( baseUrl: string, accessToken: string, filePath: string, retryOptions?: Parameters<typeof secureFetchWithRetry>[2] )
| 129 | * Fetches a single note as structured JSON with content, frontmatter, stats, and tags. |
| 130 | */ |
| 131 | async function fetchNote( |
| 132 | baseUrl: string, |
| 133 | accessToken: string, |
| 134 | filePath: string, |
| 135 | retryOptions?: Parameters<typeof secureFetchWithRetry>[2] |
| 136 | ): Promise<NoteJson> { |
| 137 | const response = await secureFetchWithRetry( |
| 138 | `${baseUrl}/vault/${filePath.split('/').map(encodeURIComponent).join('/')}`, |
| 139 | { |
| 140 | method: 'GET', |
| 141 | headers: { |
| 142 | Authorization: `Bearer ${accessToken}`, |
| 143 | Accept: 'application/vnd.olrapi.note+json', |
| 144 | }, |
| 145 | }, |
| 146 | retryOptions |
| 147 | ) |
| 148 | |
| 149 | if (!response.ok) { |
| 150 | throw new Error(`Obsidian API error fetching ${filePath}: ${response.status}`) |
| 151 | } |
| 152 | |
| 153 | return (await response.json()) as NoteJson |
| 154 | } |
| 155 | |
| 156 | /** |
| 157 | * Extracts a display title from a file path. |
no test coverage detected