MCPcopy Create free account
hub / github.com/TanStack/db / update

Function update

examples/electron/offline-first/src/utils/api.ts:36–50  ·  view source on GitHub ↗
(
    id: string,
    data: { text?: string; completed?: boolean },
  )

Source from the content-addressed store, hash-verified

34 },
35
36 async update(
37 id: string,
38 data: { text?: string; completed?: boolean },
39 ): Promise<Todo | null> {
40 const response = await fetch(`${BASE_URL}/api/todos/${id}`, {
41 method: 'PUT',
42 headers: { 'Content-Type': 'application/json' },
43 body: JSON.stringify(data),
44 })
45 if (response.status === 404) return null
46 if (!response.ok) {
47 throw new Error(`Failed to update todo: ${response.status}`)
48 }
49 return response.json()
50 },
51
52 async delete(id: string): Promise<boolean> {
53 const response = await fetch(`${BASE_URL}/api/todos/${id}`, {

Callers

nothing calls this directly

Calls 1

fetchFunction · 0.50

Tested by

no test coverage detected