Compare commits
2 commits
be182cff3f
...
85fc83cb42
| Author | SHA1 | Date | |
|---|---|---|---|
| 85fc83cb42 | |||
| 531de18ad7 |
1 changed files with 4 additions and 25 deletions
|
|
@ -116,29 +116,12 @@ export class LnbitsAPI extends BaseService {
|
||||||
|
|
||||||
if (!response.ok) {
|
if (!response.ok) {
|
||||||
const errorText = await response.text()
|
const errorText = await response.text()
|
||||||
// Try to surface FastAPI's `{"detail": "..."}` shape; fall back to raw
|
|
||||||
// body for non-JSON errors. Without this, every backend error renders
|
|
||||||
// as a generic "API request failed: <status>" and you can't distinguish
|
|
||||||
// "wrong endpoint" from "expired token" from "validation failure".
|
|
||||||
let detail: string = errorText
|
|
||||||
try {
|
|
||||||
const parsed = JSON.parse(errorText)
|
|
||||||
if (parsed && typeof parsed.detail === 'string') {
|
|
||||||
detail = parsed.detail
|
|
||||||
} else if (parsed && Array.isArray(parsed.detail)) {
|
|
||||||
// pydantic ValidationError: take the first msg
|
|
||||||
detail = parsed.detail[0]?.msg ?? errorText
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// body wasn't JSON; keep the raw text in `detail`
|
|
||||||
}
|
|
||||||
console.error('LNBits API Error:', {
|
console.error('LNBits API Error:', {
|
||||||
endpoint,
|
|
||||||
status: response.status,
|
status: response.status,
|
||||||
statusText: response.statusText,
|
statusText: response.statusText,
|
||||||
detail,
|
errorText
|
||||||
})
|
})
|
||||||
throw new Error(`LNbits ${endpoint} ${response.status}: ${detail || response.statusText}`)
|
throw new Error(`API request failed: ${response.status} ${response.statusText}`)
|
||||||
}
|
}
|
||||||
|
|
||||||
const data = await response.json()
|
const data = await response.json()
|
||||||
|
|
@ -209,12 +192,8 @@ export class LnbitsAPI extends BaseService {
|
||||||
}
|
}
|
||||||
|
|
||||||
async updateProfile(data: Partial<User>): Promise<User> {
|
async updateProfile(data: Partial<User>): Promise<User> {
|
||||||
// aiolabs/lnbits PR #26 (gap-fill 869f67c3) wired
|
return this.request<User>('/auth/update', {
|
||||||
// _publish_nostr_metadata_event into PATCH /api/v1/auth
|
method: 'PUT',
|
||||||
// (auth_api.py:546). The legacy PUT /auth/update route does not
|
|
||||||
// exist on the post-cascade server.
|
|
||||||
return this.request<User>('/auth', {
|
|
||||||
method: 'PATCH',
|
|
||||||
body: JSON.stringify(data),
|
body: JSON.stringify(data),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue