bug: improve twitter import error response

This commit is contained in:
Kieran 2023-01-26 11:02:46 +00:00
parent 64b28263d6
commit c814559655
Signed by: Kieran
GPG Key ID: DE71CEB3925BE941

View File

@ -31,14 +31,21 @@ export default function NewUserPage() {
setError("");
try {
let rsp = await fetch(`${TwitterFollowsApi}?username=${twitterUsername}`);
let data = await rsp.json();
if (rsp.ok) {
setFollows(await rsp.json());
if (Array.isArray(data) && data.length === 0) {
setError(`No nostr users found for "${twitterUsername}"`);
} else {
setFollows(data);
}
} else if ("error" in data) {
setError(data.error);
} else {
setError("Failed to load follows, is your profile public?");
setError("Failed to load follows, please try again later");
}
} catch (e) {
console.warn(e);
setError("Failed to load follows, is your profile public?");
setError("Failed to load follows, please try again later");
}
}