Guten Tag,
ich bentuze die Shopify Node.JS Api und möchte Api calls machen mit meinem Access-Token. Es klappt auch z.b kann ich mit dem Access Token meine Produkte bekommen. Problem ist aber, dass ich meine Kollektionen nicht auslesen kann, da ich 404 bad request bekomme. Weiß jemand woran das liegt ?
export const buildGetCollectionUrl = (shop: any) => `https://${shop}/admin/api/2023-04/collection_listings.json`;
export const fetchCollection = async (shop: any, accessToken: any) => await axios(buildGetCollectionUrl(shop), {
method: 'GET',
headers: {
'X-Shopify-Access-Token': accessToken,
'Content-Type': 'application/json',
}
});
app.get('/auth/callback', async (req: any, res: any) => {
try {
// The library will automatically redirect the user
const callback = await shopify.auth.callback({
rawRequest: req,
rawResponse: res,
});
const response = await shopify.webhooks.register({
session: callback.session,
});
const { data: collections } = await fetchCollection(callback.session.shop, callback.session.accessToken);
console.log(collections);
Hab jetzt nicht den Auth0 prozess reingemacht, da der jetzt unnötig ist und ich ja den access token bekomme.
Diesen Error bekomm ich:
AxiosError: Request failed with status code 404
at settle (C:\express_inngest\node_modules\axios\lib\core\settle.js:19:12)
at BrotliDecompress.handleStreamEnd (C:\express_inngest\node_modules\axios\lib\adapters\http.js:572:11)
at BrotliDecompress.emit (node:events:402:35)
at BrotliDecompress.emit (node:domain:475:12)
at endReadableNT (node:internal/streams/readable:1343:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'ERR_BAD_REQUEST',
config: {
transitional: {
silentJSONParsing: true,
forcedJSONParsing: true,
clarifyTimeoutError: false
},
adapter: 'http',
transformRequest: [ [Function: transformRequest] ],
transformResponse: [ [Function: transformResponse] ],
timeout: 0,
xsrfCookieName: 'XSRF-TOKEN',
xsrfHeaderName: 'X-XSRF-TOKEN',
maxContentLength: -1,
maxBodyLength: -1,
env: { FormData: [Function], Blob: null },
validateStatus: [Function: validateStatus],
headers: Object [AxiosHeaders] {
Accept: 'application/json, text/plain, */*',
'Content-Type': undefined,
'X-Shopify-Access-Token': 'xxxx_xxxxxxx',
'User-Agent': 'axios/1.5.0',
'Accept-Encoding': 'gzip, compress, deflate, br'
},
Natürlich hab ich ebenso meine Scopes eingestellt:
const shopify = shopifyApi({
apiKey: 'xxxx',
apiSecretKey: 'xxxx',
scopes: ['read_products', 'write_products', 'read_orders', 'write_orders', 'read_product_listings', 'write_product_listings', 'unauthenticated_read_product_listings'],
hostName: '93c5-2a02-908-4b74-122s-e9a8-dd08-43ef-4725.ngrok-free.app/',
apiVersion: LATEST_API_VERSION,
isEmbeddedApp: true
});