How to use the superagent.get function in superagent

To help you get started, we’ve selected a few superagent 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 NITDgpOS / PiZilla / src / components / files.jsx View on Github external
getFileList(dirPath) {
        const encodedPath = encodeURIComponent(dirPath);
        const files = [];
        let count = 0;

        request.get(`/files?path=${encodedPath}`, (err, res) => {
            if (err) throw err;

            files.push(<li>
                <a>PiZilla</a>
            </li>);

            // previous directory
            if (path.resolve(dirPath) !== path.resolve(this.props.path))
                files.push(<li>
                    <a data-path="..">
                        <i></i>..
                    </a>
                </li>);

            res.body.forEach(file =&gt; {
                files.push(<li><div></div></li>);
github webRunes / WRIO-InternetOS / src / iframes / webGold / js / stores / BalanceStore.js View on Github external
init() {
    var that = this;
    request
      .get("/api/webgold/get_balance")
      .set("X-Requested-With", "XMLHttpRequest")
      .withCredentials()
      .end((err, data) => {
        if (err) {
          throw new Error("Can't get balance");
        }
        console.log(data.body);
        that.balance = data.body.balance;
        Actions.Balance.trigger(that.balance);
      });
    request
      .get("/add_funds_data")
      .set("X-Requested-With", "XMLHttpRequest")
      .withCredentials()
      .end((err, data) => {
github mozilla / learning.mozilla.org / lib / badges-api.js View on Github external
getBadgeDetails: function (badgeId, callback) {
    request
      .get(this.credlyURL('/badge/' + badgeId))
      .withCredentials()
      .accept('json')
      .end(function (err, res) {
        if (err) {
          console.log('error', err);
          return callback(err, res);
        }
        callback(false, res.body);
      });
  },
github facesea / banshee / static / src / redux / modules / project.js View on Github external
return (dispatch, getState) => {
    request
      .get('/api/projects')
      .end(function (err, res) {
        if (err || !res.ok) {
          console.error('get projects error')
        } else {
          dispatch(setProjects(res.body))
        }
      })
  }
}
github tensult / aws-automation / brightcove / brightcove_videos_retranscode.js View on Github external
async function getVideosWithViewFromBrightCove(_videoIds) {
    try {
        let videoData = [];
        const dividedVideoIds = divideArrayInSubArrays(_videoIds, 5);
        for (const videoIds of dividedVideoIds) {
            const brightcoveVideosWithViewApiUrl = brightcoveDimensionApiUrl + `?accounts=${BRIGHTCOVE_ACCOUNT_ID}&dimensions=${dimensions}&where=video==${videoIds.join(",")}`;
            const retrieveVideos = await superagent.get(brightcoveVideosWithViewApiUrl).set({
                [authHeader]: await getAccessTokenAuthHeader()
            }).send().then(function (res) {
                return res.body.items;
            });
            videoData = videoData.concat(retrieveVideos);
        }
        return videoData.reduce((videosMap, video) => {
            videosMap[video.video] = video.video_view;
            return videosMap;
        }, {});
    } catch (error) {
        console.log('get', error)
    }
}
github relax / relax / lib / shared / elements / music-player / container.jsx View on Github external
loadSoundcloud () {
    request
      .get(`http://api.soundcloud.com/resolve?url=${this.props.soundcloud}&format=json&consumer_key=${CONSUMER_KEY}&callback=?`)
      .set('Accept', 'application/json')
      .end(::this.soundcloudLoaded);
  }
github clibs / clib / index.js View on Github external
function fetch(name, file, options) {
  var url = 'https://raw.github.com/' + name + '/master/' + file;
  var dst = options.to + '/' + path.basename(file);

  log('fetch', file);
  request
  .get(url)
  .end(function(res){
    if (res.error) return error(name, res, url);
    fs.writeFile(dst, res.text, function(err){
      if (err) throw err;
      log('write', dst + ' - ' + bytes(res.text.length));
    });
  });
}
github firekylin / firekylin / www / static / src / admin / store / page.js View on Github external
onSelectList(page) {
    return firekylin.request(superagent.get('/admin/api/page?page='+page)).then(
      data => this.trigger(data, 'getPageList')
    );
  },
github Hackzzila / krypton / build.js View on Github external
async function compileLibrary(name, arch, url) {
  if (fs.existsSync(path.resolve('deps', arch, name))) return;

  fs.mkdirSync(path.resolve('deps', arch, name));

  const stream = tar.x({
    strip: 1,
    cwd: path.resolve('deps', arch, name),
  });

  await get(url);

  get(url).pipe(stream);

  await new Promise(r => stream.on('finish', r));

  let cross = '';
  if (arch === 'ia32') {
    cross = '--build=x86_64-pc-linux-gnu --host=i686-pc-linux-gnu';
  } else if (arch === 'arm') {
    cross = '--build=x86_64-pc-linux-gnu --host=arm-linux-gnueabihf';
  } else if (arch === 'arm64') {
    cross = '--build=x86_64-pc-linux-gnu --host=aarch64-linux-gnu';
  }

  execSync(`./configure ${cross} --disable-shared --disable-pie --prefix=${path.resolve('deps', arch, 'install')}`, {
    stdio: 'inherit',
github boa182 / React_BM_Project / src / utils / httpclient.js View on Github external
return new Promise((resolve, reject) => {
            http.get(geturl(url))
            //传参用query,不然传不过去
            
            .query(params)
            .end((error, res) => {
                if(error){
                    reject(error)
                } else {
                    resolve(res)
                }
            })
        })
    },