Skip to content

Commit c8fb083

Browse files
Added option to pass auth header in method
1 parent a823cfb commit c8fb083

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/Modrinth.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,16 +337,20 @@ export default class Modrinth {
337337
* **Rquires authorization** with scope:
338338
* > `USER_READ`
339339
* @param userId The ID or username of the user to get the followed projects of
340+
* @param authorization The authorization header to use (if not set, the one from the options will be used)
340341
* @throws {} {@link UserNotFoundError} If the user with the given ID or username does not exist
341342
* @throws {} {@link ApiError} If an error occurs
342343
* @category Users
343344
*/
344-
getFollowedProjects(userId: string): Promise<Project[]> {
345+
getFollowedProjects(
346+
userId: string,
347+
authorization?: string
348+
): Promise<Project[]> {
345349
return new GetFollowedProjectsRoute(
346350
this.getApiUrl(),
347351
this.options.userAgent,
348352
this.cacheManager,
349-
this.options.authorization,
353+
authorization || this.options.authorization,
350354
userId
351355
).getData();
352356
}
@@ -356,17 +360,18 @@ export default class Modrinth {
356360
*
357361
* **Rquires authorization** with scope:
358362
* > `USER_READ`
363+
* @param authorization The authorization header to use (if not set, the one from the options will be used)
359364
* @throws {} {@link ApiError} If an error occurs
360365
* @throws {} {@link UnexpectedApiError} If an unexpected error occurs
361366
* @returns The authenticated user
362367
* @category Users
363368
*/
364-
getAuthUser(): Promise<User> {
369+
getAuthUser(authorization?: string): Promise<User> {
365370
return new GetAuthUserRoute(
366371
this.getApiUrl(),
367372
this.options.userAgent,
368373
this.cacheManager,
369-
this.options.authorization
374+
authorization || this.options.authorization
370375
).getData();
371376
}
372377

0 commit comments

Comments
 (0)