in src/controller/addonController.ts [30:66]
async getAddonVersions(input: string, next?: string) {
const slug: string = this.getAddonSlug(input);
const url = next
? next
: `${constants.apiBaseURL}addons/addon/${slug}/versions?filter=all_with_deleted`;
const headers = await this.credentialController.makeAuthHeader();
const response = await fetch(url, { headers });
if (!response.ok) {
const errorMessages: ErrorMessages = {
window: {
404: next
? `(Status ${response.status}): "Could not fetch more versions"`
: `(Status ${response.status}): Addon not found`,
401: `(Status ${response.status}): Unauthorized request`,
403: `(Status ${response.status}): Inadequate permissions`,
other: `(Status ${response.status}): Could not fetch versions`,
},
thrown: {
404: next ? "Failed to fetch versions" : "Failed to fetch addon",
401: "Unauthorized request",
403: "Forbidden request",
other: "Failed to fetch versions",
},
};
return await NotificationView.showErrorMessage(
errorMessages,
response.status,
this.getAddonVersions,
[input, next]
);
}
const json = await response.json();
return json;
}