Skip to content

Commit

Permalink
MWPW-161905-remove authorization header and use utils for fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
Sonja Popovic committed Nov 13, 2024
1 parent e7de663 commit 0221a2c
Showing 1 changed file with 12 additions and 34 deletions.
46 changes: 12 additions & 34 deletions edsdme/blocks/partners-navigation/features/search/gnav-search.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
closeAllDropdowns,
logErrorFor,
} from '../../utilities/utilities.js';
import { getCurrentProgramType, getLibs, getLocale, getPartnerDataCookieObject } from '../../../../scripts/utils.js';
import {getLibs} from '../../../../scripts/utils.js';
import {generateRequestForSearchAPI} from "../../../utils/utils.js";

const miloLibs = getLibs();
const { replaceKeyArray } = await import(`${miloLibs}/features/placeholders.js`);
Expand Down Expand Up @@ -129,39 +130,16 @@ class Search {
}

getSuggestions(query = this.query) {
const { env } = getConfig();
const partnerDataCookie = getPartnerDataCookieObject(getCurrentProgramType());
const partnerLevel = partnerDataCookie?.level?.toLowerCase() || 'public';
const regions = partnerDataCookie?.permissionRegion?.toLowerCase() || 'worldwide';
const specializations = partnerDataCookie?.permissionSpecializations?.toLowerCase();
const { locales } = getConfig();
const localesData = getLocale(locales);
let domain = 'https://io-partners-dx.stage.adobe.com';
if (env.name === 'prod') {
domain = 'https://io-partners-dx.adobe.com';
}
const url = new URL(
`${domain}/api/v1/web/dx-partners-runtime/search-apc/search-apc?`,
);
const queryParams = new URLSearchParams();
queryParams.append('suggestions', true);
queryParams.append('partnerLevel', partnerLevel);
queryParams.append('regions', regions);
queryParams.append('specializations', specializations);
queryParams.append('term', query);
queryParams.append('geo', localesData.prefix && localesData.region);
queryParams.append('language', localesData.ietf);
queryParams.append('size', SUGGESTIONS_SIZE);
url.search = queryParams.toString();
const headers = new Headers();
headers.append('Content-Type', 'application/json');
headers.append('Authorization', 'Basic NDA3M2UwZTgtMTNlMC00ZjZjLWI5ZTMtZjBhZmQwYWM0ZDMzOjJKMnY1ODdnR3dtVXhoQjNRNlI2NDIydlJNUDYwRDZBYnJtSzRpRTJrMDBmdlI1VGMxRXNRbG9Vc2dBYTNNSUg=');

return fetch(url.toString(), { headers, credentials: 'include' })
.then((data) => data.json())
.catch(() => {
// do nothing
});
return generateRequestForSearchAPI(
{
size: SUGGESTIONS_SIZE,
term: query,
suggestions: true,
}
).then((data) => data.json())
.catch(() => {
// do nothing
});
}

onSearchInput = debounce(() => {
Expand Down

0 comments on commit 0221a2c

Please sign in to comment.