adrianhajdin/project_ai_mern_image_generation

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

vatsal1812 opened this issue · 21 comments

@TidbitsJS can you please help ??

@vatsal1812 share the screen shot of the code

@vatsal1812 share your
code screenshot

typeerror2
typeerror1

@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.

Same problem with me also

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

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

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

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 u tell me what u have change or can u give us screenshot

yes please, share some code files or Screenshots

@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

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

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

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

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

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;

any update on this?

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

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

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