mirror of
https://github.com/withastro/astro.git
synced 2025-02-24 22:46:02 -05:00
fix: Unexpected token < in JSON at position 1 (#8827)
This commit is contained in:
parent
754c40f6ed
commit
ce3025cfa2
2 changed files with 8 additions and 3 deletions
5
.changeset/great-eyes-rest.md
Normal file
5
.changeset/great-eyes-rest.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
better error handling there whenever we don't get a normal 200 response
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue