Skip to content

Unable to add transformRequest to an endpoint #1141

@existe-deja

Description

@existe-deja

Version

module: 5.0.0-1618898588.9655d0e
nuxt: 2.15.4

Nuxt configuration

mode:

  • universal
  • spa

Nuxt configuration

login: {
  url: '/oauth/token/',
  method: 'post',
  headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
  transformRequest: [(data, headers) => {
    console.log('transformRequest', data)
    return data
  }]
}

Reproduction

https://codesandbox.io/s/pedantic-waterfall-1ze8d?file=/nuxt.config.js

What is expected?

I should be able to transform the request before it's sent.
According to the doc:

Each endpoint is used to make requests using axios. They are basically extending Axios Request Config.
But I can't add a request transformer specified in https://github.com/axios/axios#request-config

I'm trying to tranform the json data into a www-form-urlencoded data (stringified).
Poke #977

What is actually happening?

An error pops before the request is made. Specifying fn is not a function.

Steps to reproduce

Add a transformRequest Array in the endpoint definition. Or go to the reproduction link.

Additional information

Checklist

  • I have tested with the latest Nuxt version and the issue still occurs
  • I have tested with the latest module version and the issue still occurs
  • I have searched the issue tracker and this issue hasn't been reported yet

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