fix pfp uploading
This commit is contained in:
parent
d6384af097
commit
ea1f566a1c
@ -1,6 +1,9 @@
|
||||
export type ReqOptions = {
|
||||
headers?: {[key: string]: string} | null
|
||||
}
|
||||
|
||||
export type RequestOptions = {
|
||||
headers?: { [key: string]: string },
|
||||
|
||||
}
|
||||
|
||||
export type Res = {
|
||||
|
@ -98,10 +98,11 @@ const Profile = () => {
|
||||
button.disabled = true;
|
||||
|
||||
const body = new FormData();
|
||||
body.set('file', file, file.name);
|
||||
// body.set('name', file.name);
|
||||
body.append('file', file, file.name);
|
||||
|
||||
const response = await post('/api/user/avatar', body, { headers: {} });
|
||||
const response = await post('/api/user/avatar', body, {
|
||||
headers: null
|
||||
});
|
||||
if (!response.success) setError(response.message || 'Unknown error');
|
||||
else setFile(null);
|
||||
button.disabled = false;
|
||||
|
@ -1,5 +1,5 @@
|
||||
import { User } from "../@types/ApiStructures";
|
||||
import { RequestOptions, ClientSettings, Res } from "../@types/Other";
|
||||
import { RequestOptions, ClientSettings, Res, ReqOptions } from "../@types/Other";
|
||||
|
||||
type HttpOpts = {
|
||||
body?: string,
|
||||
@ -66,7 +66,7 @@ const parseResponse = async (response: Response): Promise<Res> => {
|
||||
return { ...base, message: await response.text() };
|
||||
};
|
||||
|
||||
export const post = async (url: string, body?: object | string, opts: RequestOptions = {}) => {
|
||||
export const post = async (url: string, body?: object | string, opts: ReqOptions = {}) => {
|
||||
|
||||
const options: HttpOpts & RequestOptions = {
|
||||
method: 'post'
|
||||
|
Loading…
Reference in New Issue
Block a user