Member-only story
Even though this example require Node.js, you don’t have to be afraid if you only got frontend experience. This requires minimal Javascript knowledge.
I once wanted to fetch an open third party API, which consisted of 150.000 objects. This took about 30 seconds to get response - which made it more or less useless for me, as a frontend developer. I want to share with you, how I solved it with minimal Node experience.
So to get started, we will setup a Node project and install express, node-fetch and cors.
mkdir node-pagination
cd node-pagination
npm init
npm install express node-fetch cors
touch index.js
Now open the project with your favourite editor.
First of all, go to your package.json file and add start to your scripts.
"scripts": {
"start": "node index.js"
}
That is all we have to change in package.json
Now go to index.js file and add
const express = require("express");
const fetch = require("node-fetch");
const cors = require("cors");
const app = express();app.use(cors())let data = null;
let url = "https://jsonplaceholder.typicode.com/albums/1/photos";