matthew-andrews/isomorphic-fetch

Unable to set Content-Type Header in POST request

NiiMER opened this issue · 3 comments

While using fetch from isomorphic-fetch it can't send the request in application/json type, it keeps sending plain/text.

After using fetch from node-fetch plugin it works!!

When calling ‘fetch()’, for the 2nd parameter do you define a ‘headers’ key:value?

Yes like the following:
fetch('http://example.domain/api/v0.2/login/', { method: 'POST', headers: { 'Content-Type': 'application/json', }, body: JSON.stringify({ userName: this.state.usernameOrEmail, password: this.state.password, }), cridentials: 'include', mode: 'no-cors', })

Do you get back and OPTIONS request?

Also, this might be a CORs issue.

JakeChampion/fetch#143 (comment)