DEV Community

San
San

Posted on

API services for Next/React JS app

export async function fetchProducts() {
  try {
    const url = "https://dummyjson.com/products/";
    const res = await fetch(url);
    const result = await res.json();
    return result;
  } catch (err) {
    console.log("error fetching products==>", err);
  }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)