-
-
Notifications
You must be signed in to change notification settings - Fork 132
Description
Hi,
I followed the docs to implement the admin with JWT Authentication support.
I followed the implementation of the code "Handle error during api documentation parsing #51"
Here is the code :
import React from 'react';
import parseHydraDocumentation from '@api-platform/api-doc-parser/lib/hydra/parseHydraDocumentation';
import {HydraAdmin, hydraClient, fetchHydra as baseFetchHydra} from '@api-platform/admin';
const entrypoint = 'https://exemple.com/api'; // Change this by your own entrypoint
const LOCAL_STORAGE_KEY_TOKEN = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
const fetchHeaders = {
'Authorization': Bearer ${LOCAL_STORAGE_KEY_TOKEN},
'Content-Type': 'application/ld+json'
};
const fetchHydra = (url, options = {}) => baseFetchHydra(url, {
...options,
headers: new Headers(fetchHeaders),
});
const restClient = api => hydraClient(api, fetchHydra);
const apiDocumentationParser = entrypoint => parseHydraDocumentation(entrypoint, {headers: new Headers(fetchHeaders)})
.then(
({api}) => ({api}),
(result) => {
switch (result.status) {
case 401:
return Promise.resolve({
api: result.api,
customRoutes: [{
props: {
path: '/',
render: () => console.log('error'), }, }], });
default:
return Promise.reject(result); } }, );
export default props => (
<HydraAdmin
apiDocumentationParser={apiDocumentationParser}
entrypoint={entrypoint}
restClient={restClient}
/>
);
I receive as an error
