Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Network Request Failed on calling fetchWithProducts #985

Closed
ArterumMC opened this issue Jul 24, 2024 · 1 comment
Closed

Network Request Failed on calling fetchWithProducts #985

ArterumMC opened this issue Jul 24, 2024 · 1 comment

Comments

@ArterumMC
Copy link

Describe the bug
When using the following method:
client.collection.fetchWithProducts(collectionId, {productsFirst: number})

An error occurs: TypeError: Network request failed. My code is correct because it works in TestFlight mode, but it does not work in dev client mode. The issue only appears on a Mac machine. There are no problems on Windows with Android device; the error only occurs with a React Native application launched from a Mac (iOS as well as Android phone).

To Reproduce
Steps to reproduce the behavior:
npx expo start
use dev client
launch project on physical device iOS or Android.
call the fetchWithProducts method

import Client from 'shopify-buy';

// Initialize Shopify-buy SDK
const client = Client.buildClient({
domain: process.env.EXPO_PUBLIC_SHOPIFY_DOMAIN,
storefrontAccessToken: process.env.EXPO_PUBLIC_SHOPIFY_STOREFRONT_TOKEN,
});

//Fetch a specific collection by a collection ID
const fetchCollectionProducts = async (collectionId: string) => {
try {
const response = await client.collection.fetchWithProducts(collectionId, { productsFirst: 25})
if (response && response.products) {
return response.products;
} else {
// return empty array if no products
return [];
}
} catch (error) {
console.error(Error fetching products for collection ${collectionId}:, error);
return [];
}

Expected behavior
This function should return the products from the Shopify database.

Environment:

"expo": "~50.0.17"
"react-native": "0.73.6"
"shopify-buy": "^2.21.1",

Additional context
All tests were conducted on physical devices. The "network request failed" error generally occurs when making a call to a local back-end, but here we are calling the Shopify API via the shopify-buy library, so I do not understand this error.

Thank you for reading,

Screens
image
image

@ArterumMC
Copy link
Author

The problem was related to an error in the .env file on iOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant