1

I want to use

const http = require('http');

says

Module not found: Error: Can't resolve 'http'

Node version: 14.18.2

React version: 17.0.2

2
  • There is no http module in the browser. Commented Jan 17, 2022 at 19:40
  • You can use the fetch API instead. Commented Jan 17, 2022 at 19:41

1 Answer 1

1

The http module is a nodejs module. On the React App, you can only use modules that leverage the browser's capabilities. For example a popular library for calling API's and such is axios, or you could just use fetch.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.