SawyerHood / draw-a-ui

Draw a mockup and generate html for it
https://draw-a-ui.com
MIT License
13.18k stars 1.58k forks source link

fetch error #22

Closed linwentao-hexin closed 9 months ago

linwentao-hexin commented 10 months ago
image

get error while fetching ...i had add proxy to the terminal or vscode, it seems it doesn't work? ....

Cuffyochick commented 10 months ago

It seem like your having trouble 🤣

giggling-ginger commented 9 months ago

Been there... Are you developing in mainland?

MXXWX commented 9 months ago

I don't know if this is a network issue. Even if I use VPN, it won't work. The API keys are all correct, just like you. Who can help me

xuanxiaoyu69 commented 9 months ago
// 安装依赖
npm install node-fetch https-proxy-agent

// 修改代码   http://127.0.0.1:7890为你的代理地址
import fetch from 'node-fetch';
import {HttpsProxyAgent} from 'https-proxy-agent';

const resp = await fetch("https://api.openai.com/v1/chat/completions", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
  },
  body: JSON.stringify(body),
  agent: new HttpsProxyAgent('http://127.0.0.1:7890')
});
linwentao-hexin commented 9 months ago
// 安装依赖
npm install node-fetch https-proxy-agent

// 修改代码   http://127.0.0.1:7890为你的代理地址
import fetch from 'node-fetch';
import {HttpsProxyAgent} from 'https-proxy-agent';

const resp = await fetch("https://api.openai.com/v1/chat/completions", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
  },
  body: JSON.stringify(body),
  agent: new HttpsProxyAgent('http://127.0.0.1:7890')
});

感谢!!解决了

111lz commented 9 months ago
// 安装依赖
npm install node-fetch https-proxy-agent

// 修改代码   http://127.0.0.1:7890为你的代理地址
import fetch from 'node-fetch';
import {HttpsProxyAgent} from 'https-proxy-agent';

const resp = await fetch("https://api.openai.com/v1/chat/completions", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
    Authorization: `Bearer ${process.env.OPENAI_API_KEY}`,
  },
  body: JSON.stringify(body),
  agent: new HttpsProxyAgent('http://127.0.0.1:7890')
});

谢谢!!解决了 我是个js小白,请问”// 修改代码“这一部分的代码添加在哪里啊,或者说是修改哪个文件呀?