shopify-api-js icon indicating copy to clipboard operation
shopify-api-js copied to clipboard

I have questions about the CLI ?

Open ClairCc opened this issue 4 years ago • 2 comments

I've been using the Shopify cli and I haven't seen the "routes" where I can do the requests, be they Post , Get , put etc. I've spent a lot of time analyzing the code and I can't create a get or a post, is there a tutorial that can help me with this

ClairCc avatar Feb 03 '22 16:02 ClairCc

@ClairCc I stopped using the shopify-cli generated app. Just published a working example using nextjs. If you know nextjs you can do whatever you want. https://github.com/redochka/nextjs-shopify-app-no-custom-server Give it a try

redochka avatar Feb 04 '22 10:02 redochka

You can't use next api routes. We tried something like this:

Component.js

const Component = () => (
const app  = useAppBridge();
const authFetch = authenticatedFetch(app);

	useEffect(() => {
		const fetchData = async () => {
			const response = await authFetch('/api/your-route')
			const data = await response.json();
		}
		fetchData()
	}, [])
...
...

server.js

	router.get(
		'/api/your-route',
		verifyRequest({ returnHeader: true }),
		async (ctx) => {
			ctx.res.statusCode = 200;
			// do things
		},
	);

jsullivan5 avatar Feb 10 '22 19:02 jsullivan5

This issue is stale because it has been open for 90 days with no activity. It will be closed if no further action occurs in 14 days.

github-actions[bot] avatar Oct 06 '22 02:10 github-actions[bot]

We are closing this issue because it has been inactive for a few months. This probably means that it is not reproducible or it has been fixed in a newer version. If it’s an enhancement and hasn’t been taken on since it was submitted, then it seems other issues have taken priority.

If you still encounter this issue with the latest stable version, please reopen using the issue template. You can also contribute directly by submitting a pull request– see the CONTRIBUTING.md file for guidelines

Thank you!

github-actions[bot] avatar Oct 20 '22 02:10 github-actions[bot]