Authenticate with EdgeGrid: Does anyone have an example to connect the akamai api using react? (vite-react)

I’ve run this command:

npm create vite@latest
.
..
...
npm install --save akamai-edgegrid

Then I tried to import, but after that the app crashed

import EdgeGrid from 'akamai-edgegrid'

ConsoleLog Error:

Uncaught ReferenceError: process is not defined
    at Object.getLogger (log4js.js:159:7)
    at node_modules/akamai-edgegrid/src/logger.js (logger.js:16:21)
    at __require2 (chunk-7RP6IU3L.js?v=5b893f19:16:50)
    at node_modules/akamai-edgegrid/src/helpers.js (helpers.js:16:14)
    at __require2 (chunk-7RP6IU3L.js?v=5b893f19:16:50)
    at node_modules/akamai-edgegrid/src/auth.js (auth.js:16:15)
    at __require2 (chunk-7RP6IU3L.js?v=5b893f19:16:50)
    at node_modules/akamai-edgegrid/src/api.js (api.js:16:12)
    at __require2 (chunk-7RP6IU3L.js?v=5b893f19:16:50)
    at node_modules/akamai-edgegrid/index.js (index.js:1:18)

Thanks for reaching out in regards to the Akamai EdgeGrid authentication library for Node.js.

What version of Node.js are you running? With the command you run you should be importing the latest akamai-edgegrid version of v3.4.4. Haven’t seen this specific error before.

I am not sure if you need the 'import EdgeGrid from ‘akamai-edgegrid’ line. I recommend creating a variable simiar to mentioned here: GitHub - akamai/AkamaiOPEN-edgegrid-node

I hope that helps.

/Mike

Thank you for your response and nice to meeet you melissen.

The problem is that I am doing the code using reactjs in fontend mode to consume the API endpoints, that’s why I only use the imports.
But the EdgeGrid is built to work in Nodejs for the backend side, so it uses the sh require('akamai-edgegrid');. that’s a problem for me.

Akamai should simplify it so that developers can only focus on consuming those endpoints quickly and safely.

I would be very grateful to any Samaritan who leaves an example repository in ReactJs to consume the AKAMAI api.

Thank you for your response and nice to meet you Melissen.

The problem is that I am doing the code using reactjs in fontend mode to consume the API endpoints, that’s why I only use the imports.
But the EdgeGrid is built to work in Nodejs for the backend side, so it uses the sh require('akamai-edgegrid');. this a problem for me.

Akamai should simplify it so that developers can only focus on consuming those endpoints quickly and safely.

I would be very grateful to any Samaritan who leaves an example repository in ReactJs to consume the AKAMAI api.

Thanks for the feedback. I will ask around our internal Developer Champions teams to see if someone has a suggestion here and if not, make sure this gets added to our NodeJs EdgeGrid roadmap.

2 Likes