I'm building a chrome extension which will need to make an API call when certain messages are received from the content script. I'm having difficulty making the HTTP request and I believe that my webpack configuration is to blame.
I've tried using node-fetch and axios and neither is working for me.
My webpack.common.js file looks like this:
const path = require("path");
module.exports = {
target: "node",
entry: {
popup: path.join(__dirname, "src/popup/index.tsx"),
background: path.join(__dirname, "src/background.ts"),
contentScript: path.join(__dirname, "src/contentScript.ts"),
},
output: {
path: path.join(__dirname, "dist"),
filename: "[name].js",
},
module: {
rules: [
{
exclude: /node_modules/,
test: /\.tsx?$/,
use: "ts-loader",
},
{
exclude: /node_modules/,
test: /\.scss$/,
use: [
{
loader: "style-loader", // Creates style nodes from JS strings
},
{
loader: "css-loader", // Translates CSS into CommonJS
},
{
loader: "sass-loader", // Compiles Sass to CSS
},
],
},
],
},
resolve: {
extensions: [".ts", ".tsx", ".js"],
},
};
When the script attempts a call with axios from the chrome extension, I receive this error:
dispatchRequest.js:52 Uncaught (in promise) TypeError: adapter is not a function
at dispatchRequest (dispatchRequest.js:52)