Open olavea opened 2 years ago
See PR with commit here
// /gatsby-node.js // added async const createCloudinaryNodes = async (gatsby, cloudinary, options) => { // added await await cloudinary.api.resources(options, (error, result) => { const hasResources = result && result.resources && result.resources.length; console.log("This is the result", result); if (error) { console.error(error); return; } if (!hasResources) { console.warn( "\n ~Yikes! No nodes created because no Cloudinary resources found. Try a different query?" ); return; } result.resources.forEach((resource) => { const transformations = "q_auto,f_auto"; // Default CL transformations, todo: fetch base transformations from config maybe. resource.url = addTransformations(resource, transformations); resource.secure_url = addTransformations(resource, transformations, true); const nodeData = getNodeData(gatsby, resource); gatsby.actions.createNode(nodeData); }); console.info( `Added ${hasResources} CloudinaryMedia ${ hasResources > 1 ? "nodes" : "node" }` ); }); };
Looks like it worked ⬇️
Det er fortsatt callbacken som gjør arbeidet, alt som liksom er inne der skal utenfor:
const result = await cloudinary.api.resources(options) // her kommer alt arbeidet som før skjedde inn i callbacken
See PR with commit here
Looks like it worked ⬇️