Skip to content

Cannot expand cross_sells.product #27

Discussion options

You must be logged in to vote

Hi!

The Frontend API (swell-js) does not support expansion of cross_sells.product. Since you're making the request on the server, you could use the Backend API instead here as it supports this expansion. Here's a snippet of how that would look like with swell-node library:

import swell from "swell-node";

export const getStaticProps = async ({ params }) => {
  swell.init(STORE_ID, STORE_SECRET_KEY);

  const product = await swell.get(`/products/${params.slug}`, {
    expand: ["cross_sells.product"],
  });

//...
})

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@ericingram
Comment options

@y3owk1n
Comment options

@ericingram
Comment options

Answer selected by siphosenkosindhlovu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
4 participants