Skip to content

Commit

Permalink
feat: use random ip by default
Browse files Browse the repository at this point in the history
  • Loading branch information
PeronGH committed Apr 11, 2023
1 parent 189d6c2 commit 0f6fc34
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions src/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,12 @@ export async function createConversation(
cookie,
};

let resp: ConversationResponse;
try {
resp = await fetch(API_ENDPOINT, { headers, redirect: "error" }).then(
(res) => res.json(),
);
if (!resp.result) {
throw new Error("Invalid response");
}
} catch (err) {
console.error("retry bing create", err);
resp = await fetch(API_ENDPOINT, {
headers: { ...headers, "x-forwarded-for": randomIP() },
redirect: "error",
}).then((res) => res.json());
if (!resp) {
throw new Error(`Failed to fetch (${API_ENDPOINT})`);
}
const resp: ConversationResponse = await fetch(API_ENDPOINT, {
headers: { ...headers, "x-forwarded-for": randomIP() },
redirect: "error",
}).then((res) => res.json());
if (!resp) {
throw new Error(`Failed to fetch (${API_ENDPOINT})`);
}

if (resp.result.value !== "Success") {
Expand Down

0 comments on commit 0f6fc34

Please sign in to comment.