Skip to content

Commit ce3025c

Browse files
author
Rishi Raj Jain
authored
fix: Unexpected token < in JSON at position 1 (#8827)
1 parent 754c40f commit ce3025c

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.changeset/great-eyes-rest.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'astro': patch
3+
---
4+
5+
better error handling there whenever we don't get a normal 200 response

packages/astro/src/cli/add/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -725,10 +725,10 @@ async function fetchPackageJson(
725725
const packageName = `${scope ? `${scope}/` : ''}${name}`;
726726
const registry = await getRegistry();
727727
const res = await fetch(`${registry}/${packageName}/${tag}`);
728-
if (res.status === 404) {
729-
return new Error();
730-
} else {
728+
if (res.status >= 200 && res.status < 300) {
731729
return await res.json();
730+
} else {
731+
return new Error();
732732
}
733733
}
734734

0 commit comments

Comments
 (0)