How to use the electron-fetch function in electron-fetch

To help you get started, we’ve selected a few electron-fetch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github horizon-games / remix-app / src / helpers / app_cache.js View on Github external
const registerAppCache = (browserWindow, userDataPath) => {

  // Attempt to fetch the list.json to determine if we're online
  // and the contents are available, in this case, we will always
  // fetch the latest list of available compilers, but fallback
  // to a local version if available.
  let getList = false
  const listURL = 'https://solc-bin.ethereum.org/bin/list.json'
  const resp = fetch(listURL)
  resp.then((resp) => {
    if (resp.status === 200) {
      getList = true
    }
  }).catch((err) => {
    getList = false
  })

  const filter = {
    urls: ['https://solc-bin.ethereum.org/bin/*']
  }

  const session = browserWindow.webContents.session

  session.webRequest.onBeforeRequest(filter, (details, callback) => {
    const resourceURL = details.url
github zeit / hyper / app / notifications.js View on Github external
export default function fetchNotifications(win) {
  const {rpc} = win;
  const retry = err => {
    setTimeout(() => fetchNotifications(win), ms('30m'));
    if (err) {
      //eslint-disable-next-line no-console
      console.error('Notification messages fetch error', err.stack);
    }
  };
  //eslint-disable-next-line no-console
  console.log('Checking for notification messages');
  fetch(NEWS_URL, {
    headers: {
      'X-Hyper-Version': version,
      'X-Hyper-Platform': process.platform
    }
  })
    .then(res => res.json())
    .then(data => {
      const {message} = data || {};
      if (typeof message !== 'object' && message !== '') {
        throw new Error('Bad response');
      }
      if (message === '') {
        //eslint-disable-next-line no-console
        console.log('No matching notification messages');
      } else {
        rpc.emit('add notification', message);
github horizon-games / remix-app / src / helpers / app_cache.js View on Github external
session.webRequest.onCompleted(filter, (details) => {
    const resourceURL = details.url

    const resp = fetch(resourceURL)

    resp.then((resp) => {
      if (resp.status === 200) {
        const filename = getFilename(resourceURL)
        const dest = fs.createWriteStream(cachedFilePath(userDataPath, resourceURL))
        resp.body.pipe(dest)
      }
    }).catch((err) => {})
  })
github canisminor1990 / bilibili-client / src / main / services / checkUpdate.js View on Github external
export default () => {
  try {
    const version = `v${appData.version}`;
    fetch('https://api.github.com/repos/canisminor1990/bilibili-client/releases/latest')
      .then(res => res.text())
      .then(body => {
        const Body = JSON.parse(body);
        const newVersion = Body['tag_name'];
        Log(
          `[app][check-update] Local: ${chalk.green(version)} Repo: ${chalk.green(
            newVersion
          )} Check: ${compare(version, newVersion)}`
        );
        if (compare(version, newVersion)) {
          dialog.showMessageBox(
            null,
            {
              buttons: ['取消', '去更新'],
              message: `检查到新版本${newVersion},您正在使用的版本是${version},是否前往更新?`,
            },
github wavebox / waveboxapp / src / app / src / Services / FetchService.js View on Github external
.then(() => {
        return fetch(url, {
          ...options,
          credentials: isSessionlessRequest ? options.credentials : undefined,
          useElectronNet: true,
          session: ses
        })
      })
      .then((res) => {
github jhen0409 / react-native-debugger / electron / update.js View on Github external
const getFeed = () =>
  fetch(`https://raw.githubusercontent.com/${repo}/master/auto_updater.json`).then(res =>
    res.json()
  );
github wavebox / waveboxapp / src / app / src / Extensions / Chrome / CRExtensionDownloader.js View on Github external
      .then(() => fetch(reqURL, { useElectronNet: true }))
      .then((res) => res.ok ? Promise.resolve(res) : Promise.reject(new Error(`Http Status not ok: ${res.httpStatus}`)))
github btargac / excel-parser-processor / src / utils / processItems.js View on Github external
const processItems = (rowItems, filePath, outputPath, win) => {

  const itemUrl = new URL(rowItems.pop());

  const itemName = path.basename(itemUrl.pathname);

  fetch(itemUrl)
    .then(response => {

      if (response.ok) {

        const dest = fs.createWriteStream(path.join(outputPath, itemName));
        response.body.pipe(dest);

        const percentage = Math.abs(++processedItemsCount / initialItemsLength) * 100;

        win.webContents.send('progress', percentage);

        if (rowItems.length) {
          processItems(rowItems, filePath, outputPath, win);
        } else {

          const logFileStream = fs.createWriteStream(path.join(
github wavebox / waveboxapp / src / app / src / Extensions / Chrome / CRExtensionDownloader.js View on Github external
      .then(() => fetch(downloadUrl, { useElectronNet: true }))
      .then((res) => res.ok ? Promise.resolve(res) : Promise.reject(new Error(`Http Status not ok: ${res.httpStatus}`)))

electron-fetch

A light-weight module that brings window.fetch to electron's background process

MIT
Latest version published 2 years ago

Package Health Score

57 / 100
Full package analysis

Popular electron-fetch functions