Skip to content

Error

Error describes a failed CosmosAsync request. When the wrapper handles a request with fetch, it resolves with this object for an error status instead of rejecting.

interface Error {
code: number;
error: string;
message: string;
stack?: string;
}
PropertyTypeDescription
codenumberThe HTTP status code.
errorstringThe HTTP status text.
messagestringThe error message.
stackstring | undefinedThe stack trace, when there is one.
const result = await Spicetify.CosmosAsync.get('https://api.spotify.com/v1/me');
if ('code' in result && result.code >= 400) console.error(result.message);