mirror of
https://github.com/lnbits/lnbits.git
synced 2025-06-25 08:11:20 +02:00
fix: handle node absent in 1ml.com (#3180)
This commit is contained in:
parent
4071925f65
commit
e6de66e1b1
@ -212,7 +212,10 @@ async def api_get_1ml_stats(node: Node = Depends(require_node)) -> Optional[Node
|
|||||||
r = await client.get(url=f"https://1ml.com/node/{node_id}/json", timeout=15)
|
r = await client.get(url=f"https://1ml.com/node/{node_id}/json", timeout=15)
|
||||||
try:
|
try:
|
||||||
r.raise_for_status()
|
r.raise_for_status()
|
||||||
return r.json()["noderank"]
|
data = r.json()
|
||||||
|
if "noderank" not in data:
|
||||||
|
return None
|
||||||
|
return data["noderank"]
|
||||||
except httpx.HTTPStatusError as exc:
|
except httpx.HTTPStatusError as exc:
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
status_code=HTTPStatus.NOT_FOUND, detail="Node not found on 1ml.com"
|
status_code=HTTPStatus.NOT_FOUND, detail="Node not found on 1ml.com"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user