Skip to content

Commit

Permalink
SDP-1095 - [FE] getting 400 when calling GET /organization/logo, on…
Browse files Browse the repository at this point in the history
… branch `sdp-multitenant` (#79)
  • Loading branch information
marwen-abid authored Mar 4, 2024
1 parent af93108 commit 6450c38
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 14 deletions.
12 changes: 10 additions & 2 deletions src/api/getOrgLogo.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
import { API_URL } from "constants/envVariables";
import { getSdpTenantName } from "helpers/getSdpTenantName";

export async function getOrgLogo(): Promise<string> {
const response = await fetch(`${API_URL}/organization/logo`);
export async function getOrgLogo(token: string): Promise<string> {
const response = await fetch(`${API_URL}/organization/logo`, {
method: "GET",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
"SDP-Tenant-Name": getSdpTenantName(),
},
});

const responseBlob = await response.blob();
return URL.createObjectURL(responseBlob);
Expand Down
28 changes: 16 additions & 12 deletions src/store/ducks/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,23 @@ export const getOrgLogoAction = createAsyncThunk<
string,
undefined,
{ rejectValue: RejectMessage; state: RootState }
>("organization/getOrgLogoAction", async (_, { rejectWithValue, dispatch }) => {
try {
return await getOrgLogo();
} catch (error: unknown) {
const apiError = normalizeApiError(error as ApiError);
const errorString = apiError.message;
endSessionIfTokenInvalid(errorString, dispatch);
>(
"organization/getOrgLogoAction",
async (_, { rejectWithValue, getState, dispatch }) => {
const { token } = getState().userAccount;
try {
return await getOrgLogo(token);
} catch (error: unknown) {
const apiError = normalizeApiError(error as ApiError);
const errorString = apiError.message;
endSessionIfTokenInvalid(errorString, dispatch);

return rejectWithValue({
errorString: `Error fetching organization logo: ${errorString}`,
});
}
});
return rejectWithValue({
errorString: `Error fetching organization logo: ${errorString}`,
});
}
},
);

export const getStellarAccountAction = createAsyncThunk<
StellarAccountInfo,
Expand Down

0 comments on commit 6450c38

Please sign in to comment.