evals
scenario-1
scenario-10
scenario-2
scenario-3
scenario-4
scenario-5
scenario-6
scenario-7
scenario-8
scenario-9
Build a tool that fetches JSON data from an HTTP endpoint and validates the response headers before processing the data. The tool should check for specific header values and respond appropriately based on the header information.
Your tool should:
X-API-Version and verify it matches an expected value/**
* Fetches JSON data from a URL and validates response headers.
*
* @param {string} url - The URL to fetch data from
* @param {string} expectedVersion - The expected value of the X-API-Version header
* @param {function} onData - Callback called for each data item in the items array
* @param {function} onComplete - Callback called when request completes successfully
* @param {function} onError - Callback called if headers are invalid or request fails
* @returns {object} The request object that can be used to abort the request
*/
function fetchWithHeaderValidation(url, expectedVersion, onData, onComplete, onError);
module.exports = { fetchWithHeaderValidation };Provides streaming JSON parsing with request lifecycle event handling.