Hey Coders, Need help with one MCQ Question | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Hey Coders, Need help with one MCQ Question

fetch (url, { method: 'post', headers: { "Content-type": ------------- }, body: 'foo=bar & lorem=ipsum' }) After considering snippet above which of the following values for the Content-Type header is/are correct? A) application/x-www-form-urlencoded; charset=UTF-8 B) text/html; charset=utf-8 C)application/json; charset=UTF-8 D)Content-Type: multipart/form-data; boundry=something According to me B and D is correct but test is failing me. Anu suggestions?

7th Oct 2022, 7:04 PM
Jojo
Jojo - avatar
2 Answers
+ 1
As i use thunder extension in Visual studio to GET or POST data . I always use header: { "Content-type":"application/json"; } and i think it's necessary to add.
7th Oct 2022, 7:12 PM
Davinder Kumar
Davinder Kumar - avatar
0
fetch api make use of application/json. This is ES6 alternative to XMLHttpRequest() object
8th Oct 2022, 6:38 PM
Kingstone Job
Kingstone Job - avatar