Skip to content

Commit

Permalink
fix: Unexpected token < in JSON at position 1 (#8827)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rishi Raj Jain authored Oct 16, 2023
1 parent 754c40f commit ce3025c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/great-eyes-rest.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

better error handling there whenever we don't get a normal 200 response
6 changes: 3 additions & 3 deletions packages/astro/src/cli/add/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -725,10 +725,10 @@ async function fetchPackageJson(
const packageName = `${scope ? `${scope}/` : ''}${name}`;
const registry = await getRegistry();
const res = await fetch(`${registry}/${packageName}/${tag}`);
if (res.status === 404) {
return new Error();
} else {
if (res.status >= 200 && res.status < 300) {
return await res.json();
} else {
return new Error();
}
}

Expand Down

0 comments on commit ce3025c

Please sign in to comment.