mirror of
https://github.com/wassname/chatGPTBox.git
synced 2026-07-24 13:00:14 +08:00
patch: fix(upgrade) bing client (#505)
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
import Browser from 'webextension-polyfill'
|
||||
|
||||
/**
|
||||
* @param {RequestInfo|URL} input
|
||||
* @param {RequestInit=} init
|
||||
* @returns {Promise<Response>}
|
||||
*/
|
||||
export function fetchBg(input, init) {
|
||||
return new Promise((resolve, reject) => {
|
||||
Browser.runtime
|
||||
.sendMessage({
|
||||
type: 'FETCH',
|
||||
data: { input, init },
|
||||
})
|
||||
.then((messageResponse) => {
|
||||
const [response, error] = messageResponse
|
||||
if (response === null) {
|
||||
reject(error)
|
||||
} else {
|
||||
const body = response.body ? new Blob([response.body]) : undefined
|
||||
resolve(
|
||||
new Response(body, {
|
||||
status: response.status,
|
||||
statusText: response.statusText,
|
||||
}),
|
||||
)
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user