0
Fork 0
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:
Rishi Raj Jain 2023-10-16 16:25:27 +05:30 committed by GitHub
parent 754c40f6ed
commit ce3025cfa2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
better error handling there whenever we don't get a normal 200 response

View file

@ -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();
}
}