@ecoding/helper.fetch
v0.0.3
Published
dev request
Downloads
15
Readme
import R from "@ecoding/helper.got"; const r = R.getInstance(); const getHttp = (env) => { r.setReqHook(async (options) => { // /api/user/ 调用 user 服务 const url = options.url; if (url.indexOf("/api/user/") !== -1) { r.setDomain("http://api.sciecomm.cn"); } return Promise.resolve(options); });
// switch (env) {
// case EnvEnum.local:
// case EnvEnum.test: {
// r.setDomain("");
// }
// default: {
// r.setDomain("");
// }
// }
return r;
} export default getHttp;
agent
import { HttpsProxyAgent } from "https-proxy-agent";
const agent = new HttpsProxyAgent("http://127.0.0.1:1087");
const completion = await r.post("https://api.openai.com/v1/chat/completions", {
model: "gpt-3.5-turbo",
messages: [{"role": "user", "content": "Say this is a test!"}],
temperature: 0.7
},
{
headers: {
"Authorization": "Bearer {Key}"
},
agent: {
http: agent,
https: agent,
}
}
);