How to pass Form Data and User-Agent to axios?

  • 0
    Good afternoon, I ran into the need to pass Form Data and User-Agent when post request axios.

    On the site to which I am making a request, with a mobile user-agent, I need to send Form-Data.


    But unfortunately I do not know how to make a request with a specific user-agent and transfer the form-data I need, or rather, there were attempts, but they were not successful, so in case, I ask knowledgeable people to help me, with me Thanks a lot as usual;)
    JavaScript Anonymous, Jun 17, 2020

  • 1 Answers
  • 0
    // `headers` are custom headers to be sent
    headers: {'X-Requested-With': 'XMLHttpRequest'}




    // `data` is the data to be sent as the request body
    // Only applicable for request methods 'PUT', 'POST', 'DELETE , and 'PATCH'
    // When no `transformRequest` is set, must be of one of the following types:
    // - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams
    // - Browser only: FormData, File, Blob
    // - Node only: Stream, Buffer
    data: {
    firstName: 'Fred'
    }




    https://github.com/axios/axios#request-config
    Anonymous

Your Answer
To place the code, please use CodePen or similar tool. Thanks you!