Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![David Mulholland](https://secure.gravatar.com/avatar/2b94e2c4f1420229ea30c4c0b461117e?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
David Mulholland
Full Stack JavaScript Techdegree Graduate 24,063 PointsCant get a response to the console when I post using fetch()
As above, can someone check my code it is not working for some reason, thanks.
// ------------------------------------------ // EVENT LISTENERS // ------------------------------------------ select.addEventListener('change', fetchBreedImage); card.addEventListener('click', fetchBreedImage); form.addEventListener('submit', postData);
// --------------------
function postData(e) {s e.preventDefault(); const name = document.getElementById('name').value; const comment = document.getElementById('comment').value; fetch('https://jsonplaceholder.typicode.com/comments', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ name, comment}) }) .then(checkStatus) .then(res => res.json()) .then(data => console.log(data))
}
2 Answers
![Steven Parker](https://uploads.teamtreehouse.com/production/profile-photos/969492/micro_tool_chess_set_2.jpg)
Steven Parker
230,688 PointsThe unformatted code is a bit hard to read, and I don't have a context for testing it (could you post a link to a workspace snapshot next time?) But one thing caught my eye:
function postData(e) {
s e.preventDefault();
// ^
// what's that letter "s" doing there?
![David Mulholland](https://secure.gravatar.com/avatar/2b94e2c4f1420229ea30c4c0b461117e?s=96&d=https%3A%2F%2Fecs-static.teamtreehouse.com%2Fassets%2Fcontent%2Fdefault_avatar-445fbbabfc8dc9188fb5967fe43322ee0c3e0dd1e10f378bf8343784af5a13eb.webp&r=pg)
David Mulholland
Full Stack JavaScript Techdegree Graduate 24,063 PointsHello Steven, thanks removing the s sorted it out