How to use the ky function in ky

To help you get started, we’ve selected a few ky 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 ralscha / blog2019 / ky / client / src / main.js View on Github external
async function bodyMethods() {
  console.log('with fetch');
  let response = await fetch('http://localhost:8080/simple-get');
  let body = await response.text();
  console.log('body: ', body);

  console.log('without body method');
  response = await ky('http://localhost:8080/simple-get');
  body = await response.text();
  console.log('body: ', body);

  console.log('without body method');
  response = await ky.get('http://localhost:8080/simple-get');
  body = await response.text();
  console.log('body: ', body);

  console.log('with json()');
  body = await ky.get('http://localhost:8080/simple-get').json();
  console.log('body: ', body);

  console.log('with text()');
  body = await ky.get('http://localhost:8080/simple-get').text();
  console.log('body: ', body);

ky

Tiny and elegant HTTP client based on the browser Fetch API

MIT
Latest version published 11 days ago

Package Health Score

91 / 100
Full package analysis