How to use the popsicle.get function in popsicle

To help you get started, we’ve selected a few popsicle 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 jcoreio / crater / test / integration / integrationTests.js View on Github external
async function navigateTo(url) {
  if (process.env.DUMP_HTTP) {
    const res = await popsicle.get(url)
    /* eslint-disable no-console */
    console.log(`GET ${url} ${res.status}`)
    console.log(res.headers)
    console.log(res.body)
    /* eslint-enable no-console */
  }
  await browser.url(url)
}
github jcoreio / crater / test / integration / integrationTests.js View on Github external
it('renders contents of home page', async () => {
      const html = (await popsicle.get(process.env.ROOT_URL)).body
      expect(html).to.match(/Welcome to Crater!/)
    })
    it('renders contents of about page', async () => {
github LiskHQ / lisk-sdk / test / common / utils / wait_for.js View on Github external
function nodeStatus(baseUrl, cb) {
	const request = popsicle.get(
		`${baseUrl || __testContext.baseUrl}/api/node/status`
	);

	request.use(popsicle.plugins.parse(['json']));

	request.then(res => {
		if (res.status !== 200) {
			return setImmediate(
				cb,
				['Received bad response code', res.status, res.url].join(' ')
			);
		}
		return setImmediate(cb, null, res.body.data);
	});

	request.catch(err => {
github LiskHQ / lisk-sdk / test / common / utils / wait_for.js View on Github external
doWhilstCb => {
			const request = popsicle.get(
				`${baseUrl || __testContext.baseUrl}/api/node/status`
			);

			request.use(popsicle.plugins.parse(['json']));

			request.then(res => {
				if (res.status !== 200) {
					return doWhilstCb(
						['Received bad response code', res.status, res.url].join(' ')
					);
				}
				__testContext.debug(
					'Waiting for block:'.grey,
					'Height:'.grey,
					res.body.data.height,
					'Target:'.grey,
github LiskHQ / lisk-sdk / test / common / utils / wait_for.js View on Github external
(function fetchBlockchainStatus() {
		popsicle
			.get(`${baseUrl}/api/node/status`)
			.then(res => {
				retries -= 1;
				res = JSON.parse(res.body);
				if (!res.data.loaded && retries >= 0) {
					if (!doNotLogRetries) {
						__testContext.debug(
							`Retrying ${totalRetries -
								retries} time loading blockchain in next ${timeout /
								1000.0} seconds...`
						);
					}
					return setTimeout(() => {
						fetchBlockchainStatus();
					}, timeout);
				}
github LiskHQ / lisk-sdk / test / integration / utils / http.js View on Github external
getNodeStatus(port, ip) {
		return popsicle
			.get({
				url: endpoints.versions[currentVersion].getNodeStatus(
					ip || '127.0.0.1',
					port || 4000
				),
				headers,
			})
			.then(res => {
				return JSON.parse(res.body).data;
			});
	},
github LiskHQ / lisk-desktop / src / utils / api / btc / service.js View on Github external
export const getDynamicFees = () => new Promise(async (resolve, reject) => {
  try {
    const config = getBtcConfig(0);
    const response = await popsicle.get(config.minerFeesURL)
      .use(popsicle.plugins.parse('json'));
    const json = response.body;

    if (response) {
      resolve({
        Low: json.hourFee,
        Medium: json.halfHourFee,
        High: json.fastestFee,
      });
    } else {
      reject(json);
    }
  } catch (error) {
    reject(error);
  }
});
github LiskHQ / lisk-desktop / src / utils / api / lsk / liskService.js View on Github external
}) => new Promise((resolve, reject) => {
  serverUrl = networkConfig ? getServerUrl(networkConfig) : serverUrl;
  popsicle.get(`${serverUrl}${path}?${new URLSearchParams(searchParams)}`)
    .use(popsicle.plugins.parse('json'))
    .then((response) => {
      if (response.statusType() === 2) {
        resolve(transformResponse(response.body));
      } else {
        reject(new Error(response.body.message || response.body.error));
      }
    }).catch((error) => {
      if (error.code === 'EUNAVAILABLE') {
        const networkName = getNetworkNameBasedOnNethash(networkConfig);
        error = new Error(i18n.t('Unable to connect to {{networkName}}', { networkName }));
      }
      reject(error);
    });
});