I’ve been setting up a Shopify app that needs to make an API call from some information entered on custom fields on the cart page from a store.
I have the app proxy working & pointing to the Node Express route. The console.log inside is firing.
app.post("/requestEndpoint", async(req,res) => {
console.log(req)
const { body } = req;
console.log('Successful')
let status = 200
let error = null
console.log(body)
res.status(200).send({success: status === 200, error})
});
22:30:25 │ web-backend │ 'x-shopify-client-ip-sig': 'fkWXIScWz0W4g/3Lml7JmiYZ6vk=',
22:30:25 │ web-backend │ 'x-shopify-request-timing': 'cf;t=1692325825.526'
22:30:25 │ web-backend │ },
22:30:25 │ web-backend │ [Symbol(kHeadersCount)]: 84,
22:30:25 │ web-backend │ [Symbol(kTrailers)]: null,
22:30:25 │ web-backend │ [Symbol(kTrailersCount)]: 0
22:30:25 │ web-backend │ }
22:30:26 │ web-backend │ Successful
22:30:26 │ web-backend │ {}
This is the request
const options = {
method: 'POST',
headers: {
accept: 'application/json'
},
body: JSON.stringify({
pickup: {
address: {
state: 'ON',
country: 'CA',
street: '123 MAPLE STREET,
city: 'TO',
zip: 'M9W9W9'
})
}
fetch('/apps/proxy/requestEndpoint', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
The body from my fetch appears to be getting stripped away by the app proxy.