main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
605 bytes
|
Rev | Line | |
---|
[d24f17c] | 1 | import { ACCEPT_HEADER_VALUE_FOR_DOCUMENTS } from '../../constants.js';
|
---|
| 2 |
|
---|
| 3 | // eslint-disable-next-line import/prefer-default-export
|
---|
| 4 | export function makeFetchJSON(http, opts = {}) {
|
---|
| 5 | const {
|
---|
| 6 | requestInterceptor,
|
---|
| 7 | responseInterceptor
|
---|
| 8 | } = opts;
|
---|
| 9 | // Set credentials with 'http.withCredentials' value
|
---|
| 10 | const credentials = http.withCredentials ? 'include' : 'same-origin';
|
---|
| 11 | return docPath => http({
|
---|
| 12 | url: docPath,
|
---|
| 13 | loadSpec: true,
|
---|
| 14 | requestInterceptor,
|
---|
| 15 | responseInterceptor,
|
---|
| 16 | headers: {
|
---|
| 17 | Accept: ACCEPT_HEADER_VALUE_FOR_DOCUMENTS
|
---|
| 18 | },
|
---|
| 19 | credentials
|
---|
| 20 | }).then(res => res.body);
|
---|
| 21 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.