when i trying to fetch the cart api on page code, like this,
but clearly there is not a right way,
What is the best way to finish it?
what else params should I add on this?
The cart AJAX api would be wanting a variant ID - not a product ID. The error makes sense since it looks like you're sending over a product ID.
That's noted in the docs:
In the following example, quantity is the amount of the variant that you want to add and id is the variant ID of that variant. You can add multiple variants to the cart by appending more objects in the items array.