function dadJokeSearch(searchTerm) { fetch('SOMETHING GOES HERE', { // SOMETHING GOES HERE }).then(response => response.json()) .then(data => console.log(data)); } code example
Example 1: fetch and then javascript send parameters
const url = 'https://randomuser.me/api';
let data = {
name: 'Sara'
}
let fetchData = {
method: 'POST',
body: data,
headers: new Headers()
}
fetch(url, fetchData)
.then(function() {
});
Example 2: fetch suntax
fetch('http://example.com/movies.json')
.then((response) => {
return response.json();
})
.then((data) => {
console.log(data);
});