Skip to main content

I have a simple react application using amplitude-js to send payloads to our API. Our API controller accepts and parses json message (application/json;charset=utf-8) but amplitude-js sends data in format data.

I tried below code in my react application where I initiate amplitude intance but it doesn't work, it still sends the data in application/x-www-form-urlencoded format which is default:

const amplitudeInstance = amplitude.getInstance("test").init("21e0fe6c98573ae71d209cb8ec4e85eb", null, {
// optional configuration options
saveEvents: false,
forceHttps:false,
headers: {
'Content-Type': 'application/json;charset=utf-8'
},
apiEndpoint:'localhost:8080/events/publish',

logEvent:'test data'
})

So my question is why can't I change amplitude-js's content-type as they mention in docs:

https://developers.amplitude.com/docs/javascriptdeoland (Configuring HTTP Headers)

Thanks

Hi @deolandscsaping 

 

Thanks for writing into chat! Glad to help.

 

So you are configuring the HTTP headers. Do you have a domain proxy? Or what is your reason for configuring them exactly? Usually customers would not do this unless they are using a proxy, is that the case? Domain proxy article here.

 

Have you tried to send the data without configuring the headers? It usually ingests fine for me and my system can ingest it with application/json;charset=utf-8. May I ask what is your entire goal here? Maybe then I can guide you in the right way!

 

I look forward to your reply!

 

Kind Regards,

Denis

 

 


Reply