Skip to content

http.fetch always expects a reponse body #2831

@KaKi87

Description

@KaKi87

Describe the bug

http.fetch always expects a reponse body, therefore throws an error when there is none.

To Reproduce

Steps to reproduce the behavior:

  1. Run an http.fetch request that will return no response body and without defining responseType ;
  2. See the following error : Failed to parse response as JSON: SyntaxError: JSON Parse error: Unexpected EOF; try setting the responseType option to ResponseType.Text or ResponseType.Binary if the API does not return a JSON response.

Expected behavior

The request succeeds.

Platform and Versions (required):

Operating System - Linux, version 19.3 X64

Node.js environment
  Node.js - 14.18.1
  @tauri-apps/cli - 1.0.0-beta.10
  @tauri-apps/api - 1.0.0-beta.8

Global packages
  npm - 8.1.0
  yarn - 1.22.15

Rust environment
  rustc - 1.53.0
  cargo - 1.53.0

App directory structure
/dist
/node_modules
/.idea
/src
/src-tauri
/.git
/.parcel-cache

App
  tauri.rs - 1.0.0-beta.8
  build-type - bundle
  CSP - default-src blob: data: filesystem: ws: wss: http: https: tauri: 'unsafe-eval' 'unsafe-inline' 'self' img-src: 'self'
  distDir - ../dist
  devPath - http://localhost:1234

Additional context

This error was spotted during the development of axios-tauri-adapter-test, the unit test project for axios-tauri-adapter.

Stack Trace

Not applicable

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions