Skip to content

Commit

Permalink
Fix delete request with headers
Browse files Browse the repository at this point in the history
  • Loading branch information
ParthSareen committed Nov 7, 2024
1 parent 8a702a9 commit f01c1b3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
10 changes: 6 additions & 4 deletions src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -235,10 +235,12 @@ async encodeImage(image: Uint8Array | string): Promise<string> {
* @returns {Promise<StatusResponse>} - The response object.
*/
async delete(request: DeleteRequest): Promise<StatusResponse> {
await utils.del(this.fetch, `${this.config.host}/api/delete`, {
name: request.model,
headers: this.config.headers
})
await utils.del(
this.fetch,
`${this.config.host}/api/delete`,
{ name: request.model },
{ headers: this.config.headers }
)
return { status: 'success' }
}

Expand Down
3 changes: 2 additions & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const fetchWithHeaders = async (
): Promise<Response> => {
const defaultHeaders = {
'Content-Type': 'application/json',
Accept: 'application/json',
Accept: 'application/json',
'User-Agent': `ollama-js/${version} (${getPlatform()})`,
} as HeadersInit

Expand Down Expand Up @@ -211,6 +211,7 @@ export const del = async (
const response = await fetchWithHeaders(fetch, host, {
method: 'DELETE',
body: JSON.stringify(data),
headers: options?.headers
})

await checkOk(response)
Expand Down

0 comments on commit f01c1b3

Please sign in to comment.