Fix: ReferenceError: XMLHttpRequest is not defined when calling firestore DB from Next.js API routes
The error message "ReferenceError: XMLHttpRequest is not defined" typically indicates that you're trying to use the `XMLHttpRequest` object in a server-side context, such as a Next.js API route. `XMLHttpRequest` is a client-side object used for making HTTP requests in web browsers and is not available in server-side JavaScript or Node.js. If you are trying to make an HTTP request to Firestore from a Next.js API route, you should use a library like `node-fetch` or `axios` to perform the HTTP request. Here's an example of how to use `node-fetch` in a Next.js API route to access Firestore: 1. First, make sure you have `node-fetch` installed in your Next.js project: ```bash npm install node-fetch ``` 2. In your Next.js API route, use `node-fetch` to make the Firestore request: ```javascript import fetch from 'node-fetch'; export default async (req, res) => { try { // Define your Firestore API URL const firestoreUrl = 'h