Skip to content

Commit 61c6ca2

Browse files
committed
Bump version
1 parent 0bcf449 commit 61c6ca2

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lastfm-ts-api",
3-
"version": "2.4.0",
3+
"version": "2.5.0",
44
"description": "An API client for the Last.FM API written in TypeScript",
55
"keywords": [
66
"Last.FM",

src/api-request.ts

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import { createHash } from 'node:crypto';
22
import { parse, stringify } from 'node:querystring';
3+
import { IncomingMessage } from 'node:http';
34
import { request, RequestOptions } from 'node:https';
45

56
import { LastFMParams, LastFMUnknownFunction, OptionalConfig } from './types.js';
6-
import { IncomingMessage } from 'node:http';
77

88
export class LastFMApiRequest<T> {
99
public config: OptionalConfig;
@@ -91,16 +91,23 @@ export class LastFMApiRequest<T> {
9191

9292
httpRequest.end();
9393
}).then(([response, content]) => {
94-
if(response.headers['content-type'] !== 'application/json') {
95-
throw new LastFMResponseError(`lastfm-ts-api: Expected JSON response but received '${response.headers['content-type']}'`, { response, content });
94+
if (response.headers['content-type'] !== 'application/json') {
95+
throw new LastFMResponseError(
96+
`lastfm-ts-api: Expected JSON response but received '${response.headers['content-type']}'`,
97+
{ response, content }
98+
);
9699
}
97100

98101
let data;
99102

100103
try {
101104
data = JSON.parse(content);
102105
} catch (err) {
103-
throw new LastFMResponseError(`lastfm-ts-api: Unable to parse LastFM API response to JSON.`, { cause: err, response, content });
106+
throw new LastFMResponseError(`lastfm-ts-api: Unable to parse LastFM API response to JSON.`, {
107+
cause: err,
108+
response,
109+
content
110+
});
104111
}
105112

106113
if (data?.error) {
@@ -187,7 +194,7 @@ export class LastFMResponseError extends Error {
187194
public response?: IncomingMessage;
188195
public content?: string;
189196

190-
public constructor(message: string, options?: ErrorOptions & { response?: IncomingMessage, content?: string }) {
197+
public constructor(message: string, options?: ErrorOptions & { response?: IncomingMessage; content?: string }) {
191198
super(message, options);
192199
this.name = 'LastFMResponseError';
193200
const { content, response } = options ?? {};

0 commit comments

Comments
 (0)