mirror of
https://github.com/LemmyNet/lemmy-js-client.git
synced 2024-12-23 11:21:27 +00:00
fix upload urls
This commit is contained in:
parent
42bac94699
commit
4bf613ef68
1 changed files with 2 additions and 4 deletions
|
@ -176,7 +176,6 @@ type RequestOptions = Pick<RequestInit, "signal">;
|
||||||
export class LemmyHttp {
|
export class LemmyHttp {
|
||||||
#apiUrl: string;
|
#apiUrl: string;
|
||||||
#headers: { [key: string]: string } = {};
|
#headers: { [key: string]: string } = {};
|
||||||
#pictrsUrl: string;
|
|
||||||
#fetchFunction: typeof fetch = fetch.bind(globalThis);
|
#fetchFunction: typeof fetch = fetch.bind(globalThis);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -192,7 +191,6 @@ export class LemmyHttp {
|
||||||
},
|
},
|
||||||
) {
|
) {
|
||||||
this.#apiUrl = `${baseUrl.replace(/\/+$/, "")}/api/${VERSION}`;
|
this.#apiUrl = `${baseUrl.replace(/\/+$/, "")}/api/${VERSION}`;
|
||||||
this.#pictrsUrl = `${baseUrl}/pictrs/image`;
|
|
||||||
|
|
||||||
if (options?.headers) {
|
if (options?.headers) {
|
||||||
this.#headers = options.headers;
|
this.#headers = options.headers;
|
||||||
|
@ -1881,7 +1879,7 @@ export class LemmyHttp {
|
||||||
): Promise<UploadImageResponse> {
|
): Promise<UploadImageResponse> {
|
||||||
const formData = createFormData(image);
|
const formData = createFormData(image);
|
||||||
|
|
||||||
const response = await this.#fetchFunction(this.#pictrsUrl, {
|
const response = await this.#fetchFunction("/api/v4/image", {
|
||||||
...options,
|
...options,
|
||||||
method: HttpType.Post,
|
method: HttpType.Post,
|
||||||
body: formData as unknown as BodyInit,
|
body: formData as unknown as BodyInit,
|
||||||
|
@ -1901,7 +1899,7 @@ export class LemmyHttp {
|
||||||
): Promise<SuccessResponse> {
|
): Promise<SuccessResponse> {
|
||||||
const formData = createFormData(image);
|
const formData = createFormData(image);
|
||||||
|
|
||||||
const response = await this.#fetchFunction(this.#pictrsUrl, {
|
const response = await this.#fetchFunction("/api/v4/account/avatar", {
|
||||||
...options,
|
...options,
|
||||||
method: HttpType.Post,
|
method: HttpType.Post,
|
||||||
body: formData as unknown as BodyInit,
|
body: formData as unknown as BodyInit,
|
||||||
|
|
Loading…
Reference in a new issue