-
Notifications
You must be signed in to change notification settings - Fork 299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Failed to fetch when generating an image #16
Comments
Sometimes it's working and sometimes not |
Even I'm facing the same issue. Were you able to resolve it? |
Same here, and I thought was just me, still looking for some way to resolve that |
Instead of alert use console.log(error) in the createPost page then see in detail what the issue is then solve or ask. |
I have fixed this issue by |
I got the same error and created new api key from openai too but this didnt solve my problem |
Same issue...tried using 4 different api keys but doesn't work |
Keep trying with new API keys, my issue was resolved like this only. |
Try reinstalling the nodemon: For Linux: For Windows: |
But there's no url in the Home. jsx file..
…On Tue, 28 Mar, 2023, 10:01 pm Abdul Basit, ***@***.***> wrote:
My issue was resolved by changing the localhost URL as follows,
Change the localhost URL in the client/src/pages/Home.jsx to: "
http://localhost:8080/api/v1/post".
Change the localhost URL in the client/src/pages/CreatePost.jsx to: "
http://localhost:8080/api/v1/dalle"
—
Reply to this email directly, view it on GitHub
<#16 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AXZJXR234RASMNCFP4H7V73W6MG7VANCNFSM6AAAAAAUKMMAVY>
.
You are receiving this because you commented.Message ID:
***@***.***
.com>
|
There is in the line 29. |
I can't move onto further steps because of this issue, someone please resolve this..
dalleRoutes.js
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.send('Hello from DALL-E!' );
});
router.route('/').post(async (req, res) => {
try {
const { prompt } = req.body;
} catch (error) {
console.error(error);
res.status(500).send(error?.response.data.error.message);
}
});
export default router;
CreatePost.jsx
const generateImage = async () => {
if (form.prompt) {
try {
setGeneratingImg(true);
const response = await fetch('http://localhost:8080/api/v1/dalle', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
prompt: form.prompt,
}),
})
}
The text was updated successfully, but these errors were encountered: