Skip to content

Property 'statusCode' does not exist on type 'FetchError<any>' #278

@misbahansori

Description

@misbahansori

Environment

Node : v16.14.2
ofetch: "^1.3.2",

Reproduction

try {
    await $fetch("/contact", {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
      },
      baseURL: runtimeConfig.public.apiUrl,
      body: form.value,
    });
  } catch (error) {
    if (!(error instanceof FetchError)) throw error;

    if (error.statusCode !== 422) throw error;
              // ^Property 'statusCode' does not exist on type 'FetchError<any>'.ts(2339)
    errors.value = error.data.errors;
                                  // ^Property 'data' does not exist on type 'FetchError<any>'.ts(2339)
  }

Describe the bug

After upgrading to version 1.3.2, the following error message appears. I can confirm that the error message does not appear in version 1.3.1.

Additional context

No response

Logs

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions