Skip to content

fix: fine tuning ad fixes #319

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

Merged
merged 4 commits into from
Jul 1, 2022

Conversation

malikalahfaoui
Copy link
Contributor

Q A
Branch? main for features / current stable version branch for bug fixes
Tickets #...
License MIT
Doc PR api-platform/docs#...

return {
paths,
fallback: true,
};
} catch (e) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response declared in try block but used outside

@@ -54,29 +76,6 @@ export const getStaticPaths: GetStaticPaths = async () => {
fallback: true,
};
}

const view = response.data['{{{hydraPrefix}}}view'];
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

response declared in try block but used outside

@@ -36,12 +36,13 @@ export const fetch = async (id: string, init: RequestInit = {}) => {
const resp = await isomorphicFetch(ENTRYPOINT + id, init);
if (resp.status === 204) return;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TypeError: body used already for...

@@ -2,15 +2,15 @@ import { FunctionComponent, useState } from 'react';
import Link from 'next/link';
import { useRouter } from "next/router";
import { fetch } from "../../utils/dataAccess";
import ReferenceLinks from '../common/ReferenceLinks';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReferenceLinks not used on Show.tsx I just cleaned the code

await fetch(`/{{{name}}}?page=${page}`).data["{{{hydraPrefix}}}member"].map(({{{lc}}}) => `${ {{~lc}}['@id'] }/edit`)
);
}
} catch (e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can remove this try/catch then.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe should we move this complex logic to a helper function to avoid code duplication?

await fetch(`/{{{name}}}?page=${page}`).data["{{{hydraPrefix}}}member"].map(({{{lc}}}) => `${ {{~lc}}['@id'] }`)
);
}
} catch (e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this try/catch.

return {
props: {
{{{lc}}}: await fetch(`/{{{name}}}/${params.id}`),
{{{lc}}}: response.data,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't it better to pass the full response (including headers etc)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated after the use of react query

await fetch(`/{{{name}}}?page=${page}`).data["{{{hydraPrefix}}}member"].map(({{{lc}}}) => `${ {{~lc}}['@id'] }/edit`)
);
}
} catch (e) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe should we move this complex logic to a helper function to avoid code duplication?

@malikalahfaoui malikalahfaoui force-pushed the fix/fineTuning branch 6 times, most recently from ce0d1d7 to f188d95 Compare March 16, 2022 23:13
@alanpoulain alanpoulain merged commit 4ab98db into api-platform:main Jul 1, 2022
@alanpoulain
Copy link
Member

Thanks @malikalahfaoui!

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

Successfully merging this pull request may close these issues.

3 participants