<p dir="auto">If I use this function with FormData as the data automatically changes Content-type headers to<br>
<em>Content-Type: multipart/form-data; boundary=----WebKitFormBoundarygUCRrzJieLA2q33y</em><br>
ignoring my custom header.</p>
<p dir="auto">If i use the function with data empty it sends properly my custom header. I have a createProduct function using POST with the same FormData and header and it works great. I don't know what I'm doing wrong :(</p>
<p dir="auto">This is my code:</p>
<p dir="auto"><code class="notranslate">static updateProduct(data, id_product) { const url = ${API_BASE_URL}+'/producto/'+${id_product}; return axios.put(url, data, { headers: {'Content-Type': 'application/json'}; }); }</code></p>
<div class="highlight highlight-source-js notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="axios({
                method: &quot;PUT&quot;,
                url: url,
                transformRequest: [function (data, headers) {
                    // Do whatever you want to transform the data
                    return formData;
                }],
                headers: {
                    'Content-Type': file.type
                },
                &quot;withCredentials&quot;: false
            });"><pre class="notranslate"><span class="pl-en">axios</span><span class="pl-kos">(</span><span class="pl-kos">{</span>
                <span class="pl-c1">method</span>: <span class="pl-s">"PUT"</span><span class="pl-kos">,</span>
                <span class="pl-c1">url</span>: <span class="pl-s1">url</span><span class="pl-kos">,</span>
                <span class="pl-c1">transformRequest</span>: <span class="pl-kos">[</span><span class="pl-k">function</span> <span class="pl-kos">(</span><span class="pl-s1">data</span><span class="pl-kos">,</span> <span class="pl-s1">headers</span><span class="pl-kos">)</span> <span class="pl-kos">{</span>
                    <span class="pl-c">// Do whatever you want to transform the data</span>
                    <span class="pl-k">return</span> <span class="pl-s1">formData</span><span class="pl-kos">;</span>
                <span class="pl-kos">}</span><span class="pl-kos">]</span><span class="pl-kos">,</span>
                <span class="pl-c1">headers</span>: <span class="pl-kos">{</span>
                    <span class="pl-s">'Content-Type'</span>: <span class="pl-s1">file</span><span class="pl-kos">.</span><span class="pl-c1">type</span>
                <span class="pl-kos">}</span><span class="pl-kos">,</span>
                <span class="pl-s">"withCredentials"</span>: <span class="pl-c1">false</span>
            <span class="pl-kos">}</span><span class="pl-kos">)</span><span class="pl-kos">;</span></pre></div>
<p dir="auto">Launched request with Content-Type：<br>
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryPz13ZA77aLqgPlwB</p>