I’m new and looking for a way to include dynamic id
in the examples in the tutorial here.
Because all REST Admin API queries require a valid Shopify access token, all example must use inside headers
, action
and loader
function.
I make code example with the Remix code:
export const loader = async ( { request, params } ) => {
const { admin, session } = await authenticate.admin( request );
const data = await admin.rest.resources.Asset.all({
session: session,
theme_id: params.id, // Pass id here
asset: {"key": "sections/header.liquid"}
});
return json( { data } );
}
const App = () => {
const { data } = useLoaderData();
console.log( data );
return (
// Is there any way without using Form and useActionData?
<button id="136012988610" onClick={ /* Pass this button id when click */ }>Delete section from this theme</button>
);
};
export default App;
I want when I click on the Delete button, the corresponding id will be transmitted for processing. I’ve been struggling for a long time but still can’t find a way to handle it.
Does anyone have any suggestions or solutions that can assist me?
Thank you guys