Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

How to query the database through the post purchase extension

How to query the database through the post purchase extension

crismdi
Shopify Partner
1 0 0

I'm creating a post-purchase extension and I would like to know if it is possible to make calls to my database from the app that will be hosted on my server?
Or if I can only make calls to the shopify api?

 

Using this example from the documentation, instead of "APP_URL" it would be the address of my application

 

/ Faça uma solicitação ao servidor do seu aplicativo para assinar o conjunto de alterações com a chave secreta da API do seu aplicativo.  token const = aguardar busca(`${APP_URL}/api/sign-changeset`, {    método: "POSTAR",    cabeçalhos: {      Autorização: `Bearer ${inputData.token}`,      "Tipo de conteúdo": "aplicativo/json",    },    corpo: JSON.stringify({      ID de referência: inputData.initialPurchase.referenceId,      alterações: compraOption.id,    }),  })    .then((resposta) => resposta.json())    .then((resposta) => resposta.token)    .catch((e) => console.log(e));

 

Reply 1 (1)

Liam
Community Manager
3108 344 911

Hi Crismdi,

 

You should be able to make calls to your own database from the post-purchase extension. The extension code that runs on the client-side browser can interact with your server. This server can then perform operations like reading from or writing to your database. 

 

Hope this helps,

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog