79629719

Date: 2025-05-20 02:58:51
Score: 0.5
Natty:
Report link

I was trying to find something in the source code on GitHub to help me confirm this, so I will be working on an assumption.

What Axios is probably setting as a default of data is probably {}, and it will then set the content-length header because there is a data object, it's just that the object contains no data.

When you set the data argument to null, this is telling Axios that you are not sending any data at all. If data is not being sent, why would we need to set the content-length header?

Looking at the typescript in Axios's source code, they set data to be defined or optional.

post<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;

Because of this, I do not believe they intend for null to be passed in as an argument, and can explain why this is happening.

So this begs the question as well, is your backend expecting a content-length for this method? If so, then why are you sending no data at all or is this a limitation of whichever framework you are using?

Reasons:
  • Blacklisted phrase (1): help me
  • Long answer (-1):
  • Has code block (-0.5):
  • Ends in question mark (2):
  • High reputation (-1):
Posted by: Matthew