Skip to content

Commit

Permalink
STCOR-747: Provide optional tenant argument to useOkapiKy hook
Browse files Browse the repository at this point in the history
  • Loading branch information
mariia-aloshyna committed Oct 11, 2023
1 parent f02c954 commit 6330c49
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
* *BREAKING* bump `react-intl` to `v6.4.4`. Refs STCOR-744.
* Bump `stylelint` to `v15` and `stylelint-config-standard` to `v34`. Refs STCOR-745.
* Read ky timeout from stripes-config value. Refs STCOR-594.
* Provide optional tenant argument to `useOkapiKy` hook. Refs STCOR-747.

## [9.0.0](https://github.com/folio-org/stripes-core/tree/v9.0.0) (2023-01-30)
[Full Changelog](https://github.com/folio-org/stripes-core/compare/v8.3.0...v9.0.0)
Expand Down
6 changes: 3 additions & 3 deletions src/useOkapiKy.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import ky from 'ky';
import { useStripes } from './StripesContext';

export default () => {
const { locale = 'en', timeout = 30000, tenant, token, url } = useStripes().okapi;
export default (tenant) => {
const { locale = 'en', timeout = 30000, tenant: currentTenant, token, url } = useStripes().okapi;

return ky.create({
prefixUrl: url,
hooks: {
beforeRequest: [
request => {
request.headers.set('Accept-Language', locale);
request.headers.set('X-Okapi-Tenant', tenant);
request.headers.set('X-Okapi-Tenant', tenant ?? currentTenant);
request.headers.set('X-Okapi-Token', token);
}
]
Expand Down

0 comments on commit 6330c49

Please sign in to comment.