mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: Update node-fetch (#19059)
node-fetch is now a ES module, so it has to either imported with `import/from` syntax (which can't be used in addon's index.js) or using the dynamic `import()`
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
const express = require("express");
|
||||
const fetch = require("node-fetch");
|
||||
const { encode } = require("html-entities");
|
||||
const cleanBaseURL = require("clean-base-url");
|
||||
const path = require("path");
|
||||
@@ -258,6 +257,7 @@ async function buildFromBootstrap(proxy, baseURL, req, response, preload) {
|
||||
url.searchParams.append("preview_theme_id", reqUrlPreviewThemeId);
|
||||
}
|
||||
|
||||
const { default: fetch } = await import("node-fetch");
|
||||
const res = await fetch(url, { headers: req.headers });
|
||||
const json = await res.json();
|
||||
|
||||
@@ -310,6 +310,7 @@ async function handleRequest(proxy, baseURL, req, res) {
|
||||
req.headers["X-Discourse-Ember-CLI"] = "true";
|
||||
}
|
||||
|
||||
const { default: fetch } = await import("node-fetch");
|
||||
const response = await fetch(url, {
|
||||
method: req.method,
|
||||
body: /GET|HEAD/.test(req.method) ? null : req.body,
|
||||
|
||||
@@ -25,6 +25,6 @@
|
||||
"express": "^4.18.2",
|
||||
"html-entities": "^2.3.3",
|
||||
"jsdom": "^20.0.2",
|
||||
"node-fetch": "^2.6.6"
|
||||
"node-fetch": "^3.3.0"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user