Skip to content

HydraAdmin component isn't working with no entrypoint props #210

@Ancien1

Description

@Ancien1

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

Capture du 2019-09-17 16-17-54

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions