Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
Ancien1 opened this issue Sep 17, 2019 · 0 comments
Closed

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

Ancien1 opened this issue Sep 17, 2019 · 0 comments

Comments

@Ancien1
Copy link

Ancien1 commented Sep 17, 2019

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

@Ancien1 Ancien1 closed this as completed Sep 26, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant