How to use the ky/umd.post 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 peterbe / whatsdeployed / src / DeployPage.js View on Github external
async fetchShas() {
    const { owner, repo, deployments } = this.state;
    this.startLoad('shas');
    try {
      const res = await ky
        .post('/shas', { json: { owner, repo, deployments } })
        .json();

      if (res.error) {
        this.setState({ error: res.error });
      } else {
        this.setState({
          deployInfo: res.deployments,
          tags: res.tags
        });
      }
    } catch (error) {
      console.warn('Error fetching shas!');
      console.error(error);
      this.setState({ error });
    } finally {
github peterbe / whatsdeployed / src / shortUrls.js View on Github external
async fetchFor(longUrl) {
    const { url: shortUrl } = await ky
      .post('/shortenit', { json: { url: longUrl } })
      .json();
    shortUrls.addShortUrl(shortUrl);
    return shortUrl;
  },
github peterbe / whatsdeployed / src / DeployPage.js View on Github external
async fetchCulprits() {
    const { owner, repo, deployInfo } = this.props;
    this.setState({ loading: true });

    const { signal } = this.controller;
    try {
      const res = await ky
        .post('/culprits', {
          signal,
          json: { owner, repo, deployments: deployInfo }
        })
        .json();
      if (this.dismounted) return;
      if (res.error) {
        this.setState({ error: res.error });
      } else {
        this.setState({ culprits: res.culprits });
      }
    } catch (error) {
      if (this.dismounted) return;
      this.setState({ error });
    } finally {
      if (this.dismounted) return;

ky

Tiny and elegant HTTP client based on the Fetch API

MIT
Latest version published 2 months ago

Package Health Score

94 / 100
Full package analysis