harry young
harry young

Reputation: 770

TypeError: http.ServerResponse is undefined

I've been building my React app (using create-react-app) and suddenly I have hit the following error: TypeError: http.ServerResponse is undefined

I was in the process of adding a delete comment functionality that sends off a delete request using axios, if that makes a difference.

I'm new to React and have no idea what to do, now. How do I debug this?

Help very much appreciated!

I'm using axios if that helps, node backend and react.

Upvotes: 1

Views: 3960

Answers (3)

Justin Williams
Justin Williams

Reputation: 1

The imports have an random import e from "express"; at the top! At least this is my fix.

Upvotes: 0

Sören Schilling
Sören Schilling

Reputation: 71

Thanks for your answer - this saved me a lot of time. I had a very similar situation with the same error message but in Vue.JS, after moving

axios.post(...).then(response => {...}).catch();

via copy+paste from a component to Vuex store file, VSCode added import { response } from 'express'; to the top of my store file causing this error and App crash. So watch out for express imports!

Upvotes: 7

harry young
harry young

Reputation: 770

somehow vscode provided an auto import "e from 'express'" which was causing the issue.

Upvotes: 5

Related Questions