in packages/search-ui-workplace-search-connector/src/WorkplaceSearchAPIConnector.ts [248:269]
async performFetchRequest(apiUrl: string, payload: any) {
const jsVersion = "browser";
const metaHeader = `ent=${LIB_VERSION}-ws-connector,js=${jsVersion},t=${LIB_VERSION}-ws-connector,ft=universal`;
const searchResponse = await fetch(apiUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${this.accessToken}`,
"x-elastic-client-meta": metaHeader
},
body: JSON.stringify(payload)
});
if (searchResponse.status === 401) {
this.state.isLoggedIn = false; // Remove the token to trigger the Log in dialog
throw new Error(INVALID_CREDENTIALS);
}
const responseJson = await searchResponse.json();
return responseJson;
}