#I can't seem to easily be able to use Cloudinary API with Angular

6 messages · Page 1 of 1 (latest)

hexed prism
#

I would like to use cloudinary API from Angular fronted.

I followed this one by intalling npm install cloudinary

https://cloudinary.com/documentation/node_integration

I called in cloudianryAPI instead of cloudinary because I already have the same variable from other widgets that I used by them

  import { v2 as cloudinaryAPI } from 'cloudinary'


cloudinaryAPI.config({ 
  cloud_name: 'dmruay7we', 
  api_key: '599663769358526', 
  api_secret: '5xzdnxEmcXpFfZOPoxoE0hvBiCY',
  secure: true
});


    cloudinaryAPI.api
    .delete_resources_by_tag('pickup')
    .then(result=>console.log(result));

This one errors with a super long error:

ERROR in ./node_modules/cloudinary/lib-es5/api_client/execute_request.js 17:52-67
Module not found: Error: Can't resolve 'http' in 'C:\Users\blazi\Desktop\Projects\recyswiss\node_modules\cloudinary\lib-es5\api_client'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
    - add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
    - install 'stream-http'
If you don't want to include a polyfill, you can use an empty module like this:
    resolve.fallback: { "http": false }

I cried their curl example too but even the curl tester does not seem to work:
https://cloudinary.com/documentation/admin_api#delete_resources_by_tags

https://reqbin.com/curl

curl
-X DELETE
https://599663769358526:[email protected]/v1_1/dmruay7we/resources/image/tags/pickup

I am at a loss at how to successfully call their API from Angular

sacred sparrow
#

The documentation you linked to is the documentation of

the Node.js SDK
Angular applications execute in the browser, not in NodeJS. Not only this thus can't work, but even if it did, you would share your api_secret token with all the people using your app.

#

You also shared it with us all, BTW, so you should probably revoke this secret API key and use a new one that you would keep secret.

hexed prism
#

angular sdk is only for transofrmations/reading

#

I could still use the CURL api calls right if I put my keys to env variable?