Just took the rest test in HackerRank as well, and tried:
const fetch = require('node-fetch');
and it worked as well. Gives the same fetch interface you're used to.