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

Function update

examples/react-native/offline-transactions/src/utils/api.ts:66–83  ·  view source on GitHub ↗
(
    id: string,
    data: { text?: string; completed?: boolean },
  )

Source from the content-addressed store, hash-verified

64 },
65
66 async update(
67 id: string,
68 data: { text?: string; completed?: boolean },
69 ): Promise<Todo | null> {
70 const response = await fetch(`${BASE_URL}/api/todos/${id}`, {
71 method: 'PUT',
72 headers: { 'Content-Type': 'application/json' },
73 body: JSON.stringify(data),
74 })
75 if (response.status === 404) {
76 return null
77 }
78 if (!response.ok) {
79 throw new Error(`Failed to update todo: ${response.status}`)
80 }
81 const todo: TodoResponse = await response.json()
82 return parseTodo(todo)
83 },
84
85 async delete(id: string): Promise<boolean> {
86 const response = await fetch(`${BASE_URL}/api/todos/${id}`, {

Callers

nothing calls this directly

Calls 2

parseTodoFunction · 0.85
fetchFunction · 0.50

Tested by

no test coverage detected