frontend: allow to customize content type

Pedro Lucas Porcellis porcellis@eletrotupi.com 1 month ago ba9637187a559806967edd09125f84fea8b33461
Parents: 7822d9e
1 file(s) changed
  • frontend/lib/api.ts +2 -1
frontend/lib/api.ts
@@ -54,12 +54,13 @@ endpoint: string,
54 54 options: RequestInit = {}
55 55 ): Promise<T> {
56 56 const token = await this.getStoredToken();
57 + const isFormData = options.body instanceof FormData;
57 58
58 59 const config: RequestInit = {
59 60 ...options,
60 61 headers: {
61 - 'Content-Type': 'application/json',
62 62 ...(token && { Authorization: `Bearer ${token}` }),
63 + ...(!isFormData && { 'Content-Type': 'application/json' }),
63 64 ...options.headers,
64 65 },
65 66 };