adrianhajdin / project_ai_mern_image_generation

Build and Deploy a Full Stack MERN AI Image Generation App MidJourney & DALL E Clone
https://jsmastery.pro
1.08k stars 302 forks source link

Getting error when I am clicking generate image "type error : failed to fetch " #57

Open vatsal1812 opened 1 year ago

vatsal1812 commented 1 year ago

@TidbitsJS can you please help ??

shukabum commented 1 year ago

@vatsal1812 share the screen shot of the code

abhiram-edupuganti commented 1 year ago

@vatsal1812 share your code screenshot

SETHEAD commented 1 year ago

typeerror2 typeerror1

SETHEAD commented 1 year ago

@vatsal1812 share your code screenshot

please let me know what to do with the error. I've attached the screenshot of the error in another reply.

If you want the screenshot of the code, please let me know of which page or code file name you want the screenshot.

ajinkyap12 commented 1 year ago

Same problem with me also

harshjain22 commented 1 year ago

exactly same error, please let me know if you have found the error

Quinn-Kiwalabye commented 1 year ago

exactly same error, please let me know if you have found the error i fixed this error by downgrading the openai to match adrian's version on package.json

ajinkyap12 commented 1 year ago

Can u tell me what u have change or can u give us screenshot

harshjain22 commented 1 year ago

exactly same error, please let me know if you have found the error i fixed this error by downgrading the openai to match adrian's version on package.json

I changed "openai": "^3.1.0" to this from version 4, but still I am getting the same error, I am stuck in this from weeks ,It would be a great help if you guide me to solve this issue my email : heyharsh22@gmail.com

harshjain22 commented 1 year ago

Can u tell me what u have change or can u give us screenshot

yes please, share some code files or Screenshots

harshjain22 commented 1 year ago

@vatsal1812 share your code screenshot

please let me know what to do with the error. I've attached the screenshot of the error in another reply.

If you want the screenshot of the code, please let me know of which page or code file name you want the screenshot.

typeerror2 typeerror1

Have you solved this error ? if yes please share the solution, I am trying to debug it from weeks

Quinn-Kiwalabye commented 1 year ago

Can u tell me what u have change or can u give us screenshot

step 1: go to the package.json file step 2: downgrade your open ai(make sure your package.json file matches adrian's file)`{ "name": "server", "version": "1.0.0", "type": "module", "description": "", "main": "index.js", "scripts": { "start": "nodemon index" }, "author": "", "license": "ISC", "dependencies": { "cloudinary": "^1.33.0", "cors": "^2.8.5", "dotenv": "^16.0.3", "express": "^4.18.2", "mongoose": "^6.8.2", "nodemon": "^2.0.20", "openai": "^3.1.0" }

}` step 3: stop your node server, by pressing ctrl c (windows) step 4: type "npm install", it will update the package json step 5: run the node server step 6: make sure that you have inported configuration, openAi from 'openai' dalle

Quinn-Kiwalabye commented 1 year ago

exactly same error, please let me know if you have found the error i fixed this error by downgrading the openai to match adrian's version on package.json

I changed "openai": "^3.1.0" to this from version 4, but still I am getting the same error, I am stuck in this from weeks ,It would be a great help if you guide me to solve this issue my email : heyharsh22@gmail.com

can you send me a screen shot of what your inspection page is saying

harshjain22 commented 1 year ago

exactly same error, please let me know if you have found the error i fixed this error by downgrading the openai to match adrian's version on package.json

I changed "openai": "^3.1.0" to this from version 4, but still I am getting the same error, I am stuck in this from weeks ,It would be a great help if you guide me to solve this issue my email : heyharsh22@gmail.com

can you send me a screen shot of what your inspection page is saying

I have made all the changes you suggested, now instead of typerror : failed to fetch I am getting this error :

image

Quinn-Kiwalabye commented 1 year ago

pl

exactly same error, please let me know if you have found the error i fixed this error by downgrading the openai to match adrian's version on package.json

I changed "openai": "^3.1.0" to this from version 4, but still I am getting the same error, I am stuck in this from weeks ,It would be a great help if you guide me to solve this issue my email : heyharsh22@gmail.com

can you send me a screen shot of what your inspection page is saying

I have made all the changes you suggested, now instead of typerror : failed to fetch I am getting this error :

image

please send your dalleRoutes code

harshjain22 commented 1 year ago

pl

exactly same error, please let me know if you have found the error i fixed this error by downgrading the openai to match adrian's version on package.json

I changed "openai": "^3.1.0" to this from version 4, but still I am getting the same error, I am stuck in this from weeks ,It would be a great help if you guide me to solve this issue my email : heyharsh22@gmail.com

can you send me a screen shot of what your inspection page is saying

I have made all the changes you suggested, now instead of typerror : failed to fetch I am getting this error : image

please send your dalleRoutes code

import express from 'express'; import * as dotenv from 'dotenv'; import {Configuration, OpenAIApi} from 'openai';

dotenv.config();

const router = express.Router();

const configuration = new Configuration({ apiKey: process.env.OPENAI_API_KEY, }); const openai = new OpenAIApi(configuration);

router.route('/').get( (req, res) => { res.status(200).json({ message : 'Hello its DALL-E here'}); });

router.route('/').post(async (req, res) => { try { const { prompt } = req.body;

    const aiResponse = await openai.createImage({
        prompt, 
        n: 1,
        size: '1024x1024',
        response_format: 'b64_json'
    });

    const image = aiResponse.data.data[0].b64_json;

    res.status(200).json( { photo : image });

} catch (error) {
    console.error(error); 
    res.status(500).send(error?.response.data.error.message );

}

} );

export default router;

Raghu994 commented 9 months ago

any update on this?

gaurav3590 commented 9 months ago

Same problem with me also,This solution can't work.

gaurav3590 commented 9 months ago

Screenshot 2023-12-01 103821 and also this error i can't solve plz some help me

harshjain22 commented 9 months ago

can you share what errors are there in the inspect tab ?

gaurav3590 commented 9 months ago

257549787-53abb81f-e8d7-40e3-90a9-4f9d5356dfd8