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

JavaScript

I don't get output with an AJAX 'POST'

Question for y’all. I think I’m having a disconnect. Here is a complete file snippet:

const XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;

//setup the json object
let jsonQuizData = {
    "nQuestionCount": 10,
    "strQuizName": "Fabricated Test One",
    "nPassingScore": 91,
    "dtmFinished": 1540338527220,
    "nMaxScore": 130,
    "nMinScore": 5,
    "nPtScore": 91,
    "strQuizId": "5sM5YLnnNMN",
    "strStatus": "C",
    "strLearnerName": "Daffy Duck",
    "strLearnerEmail": "daffy@duck.com",
    "aQuestions": [{
            "strDescription": "text of question one",
            "strCorrectResponse": true,
            "strStatus": "C",
            "strUserResponse": true,
            "nWeight": 3,
            "nPoints": 5,
            "nQuestionNumber": 1
        },
        {
            "strDescription": "text of question two",
            "strCorrectResponse": false,
            "strStatus": "C",
            "strUserResponse": true,
            "nWeight": 2,
            "nPoints": 5,
            "nQuestionNumber": 2
        },
        {
            "strDescription": "text of question three",
            "strCorrectResponse": "a",
            "strStatus": "C",
            "strUserResponse": "a",
            "nWeight": 3,
            "nPoints": 5,
            "nQuestionNumber": 3
        },
        {
            "strDescription": "text of question four",
            "strCorrectResponse": "c",
            "strStatus": "C",
            "strUserResponse": "c",
            "nWeight": 3,
            "nPoints": 5,
            "nQuestionNumber": 4
        },
        {
            "strDescription": "text of question five",
            "strCorrectResponse": "a",
            "strStatus": "C",
            "strUserResponse": "a",
            "nWeight": 2,
            "nPoints": 5,
            "nQuestionNumber": 5
        },
        {
            "strDescription": "text of question six",
            "strCorrectResponse": "d",
            "strStatus": "C",
            "strUserResponse": "d",
            "nWeight": 1,
            "nPoints": 5,
            "nQuestionNumber": 6
        },
        {
            "strDescription": "text of question seven",
            "strCorrectResponse": false,
            "strStatus": "C",
            "strUserResponse": false,
            "nWeight": 3,
            "nPoints": 5,
            "nQuestionNumber": 7
        },
        {
            "strDescription": "text of question eight",
            "strCorrectResponse": true,
            "strStatus": "C",
            "strUserResponse": true,
            "nWeight": 3,
            "nPoints": 5,
            "nQuestionNumber": 8
        },
        {
            "strDescription": "text of question nine",
            "strCorrectResponse": false,
            "strStatus": "C",
            "strUserResponse": false,
            "nWeight": 3,
            "nPoints": 5,
            "nQuestionNumber": 9
        },
        {
            "strDescription": "text of question ten",
            "strCorrectResponse": true,
            "strStatus": "C",
            "strUserResponse": true,
            "nWeight": 3,
            "nPoints": 5,
            "nQuestionNumber": 10
        }
    ]
};

//console.log(jsonQuizData);


// Send data to handler
let xhr = new XMLHttpRequest();
let baseURL = 'http://localhost:3000/quiz/';
let endPoint = '5sM5YLnnNMN_1540338527220.json';
xhr.open('POST', baseURL+endPoint, true);
xhr.setRequestHeader("Content-type", "application/json");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.send(JSON.stringify(jsonQuizData));

Am I incorrect in the expectation that the code should write a stringified JSON object, with the file name represented by the endPoint var, @ localhost:3000 to a folder entitled quiz, which resides in the root of my project?

The code runs with no errors but it also runs with no output.