I have started learning about fetch API for few days and my teacher asked me to do it immediately. He said the request for the data is none. and it response that when created successfully, the status is 201 and the new created attempt contains attempt ID and an array of questions in Data(Json). I tried to code but it not works. This is the link of the API: https://wpr-quiz-api.herokuapp.com/attempts
All the description is here. https://wpr-quiz-api.herokuapp.com/
Sorry about my bad English and the code is not so good because I just start learning it. So if you don't mind, please describe as detailed as possible.
Thank you so much
let question=[];
const inputk = document.querySelector('span');
question.push(inputk.value);
function onResponse(response){
return response.json();
}
function onsubmit(object){
const inputk = document.querySelector('span');
question=object;
}
fetch("https://wpr-quiz-api.herokuapp.com/attempts")
.then(onResponse).then(onsubmit)
<form action="https://wpr-quiz-api.herokuapp.com/attempts" method="POST">
<div>
<span></span>
<input type="radio">
<label>Option 1</label><br>
<input type="radio">
<label>Option 2</label><br>
<input type="radio">
<label>Option 3</label><br>
</div>
</form>