1 min read

Changes in Node.js 18

Published: Apr 17, 2024

Node.js 18 introduced some new cool features and one of the most useful ones is the built-in Fetch API. This means that we no longer need to use 3rd party npm packages like node-fetch because the functionality is now native and baked into Noded. Here’s an example of how you can use it:

const getAPI = async () => {
    const res = await fetch('https://pokeapi.co/api/v2/pokemon/');
    if (res.ok) {
        const data = await res.json();
        console.log(data);
    }
};
getAPI();

Another new feature in Node.js 18 is the Test Runner module. Now, we can create tests in Node.js without needing an external package. Here’s an example of how you can use it:

import test from 'node:test';
import assert from 'node:assert';

test('synchronous passing test', (t) => {
    // This test passes because it does not throw an exception.
    assert.strictEqual(1, 1);
});
← Back to blog
© Copyright 2025 by Dhanushka's Blog. Built with ♥ by Dhanushka. Last updated on 2025-12-22.