How to use the @aurelia/fetch-client.json function in @aurelia/fetch-client

To help you get started, we’ve selected a few @aurelia/fetch-client 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 aurelia / aurelia / test / realworld / src / shared / services / api-service.ts View on Github external
public async post(path: string, body = {}) {
    const options = {
      body: json(body),
      headers: this.setHeaders(),
      method: 'POST',
    };
    try {
      const response = await this.http.fetch(`${config.apiUrl}${path}`, options);
      return await status(response);
    } catch (error) {
      try {
        return await parseError(error);
      } catch {
        return undefined;
      }
    }
  }
github aurelia / aurelia / test / realworld / src / shared / services / api-service.ts View on Github external
public async put(path: string, body = {}) {
    const options = {
      body: json(body),
      headers: this.setHeaders(),
      method: 'PUT',
    };
    try {
      const response = await this.http.fetch(`${config.apiUrl}${path}`, options);
      return await status(response);
    } catch (error) {
      try {
        return await parseError(error);
      } catch {
        return undefined;
      }
    }
  }

@aurelia/fetch-client

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![TypeScript](https://img.shields.io/badge/%3C%2F%3E-TypeScript-%230074c1.svg)](http://www.typescriptlang.org/) [![CircleCI](https://circleci.com/

MIT
Latest version published 1 month ago

Package Health Score

81 / 100
Full package analysis