Cors Error
const [dogData,setDogData] = useState([]);
const express = require('express');
const app = express();
const cors = require('cors');
app.cors({
origin:'*'
})
useEffect(() => {
const fetchDogData = async () =>{
try {
const response = await fetch ('https://www.billplz-sandbox.com/api', );
const data = await response.json();
console.log(data);
setDogData(data);
}
catch (err){
console.log(err);
}
}
fetchDogData();
} , [])
return (
<div></div>
)
}
I am trying to fetch data from that api also i used this method but after that i got this message in my screen .....
Module not found: Error: Can't resolve 'zlib' in 'C:\Users\HP\Desktop\React\my-app\node_modules\body-parser\lib'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "zlib": require.resolve("browserify-zlib") }'
- install 'browserify-zlib'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "zlib": false }
Without using cors i got a Cors error something related to header
const express = require('express');
const app = express();
const cors = require('cors');
app.cors({
origin:'*'
})
useEffect(() => {
const fetchDogData = async () =>{
try {
const response = await fetch ('https://www.billplz-sandbox.com/api', );
const data = await response.json();
console.log(data);
setDogData(data);
}
catch (err){
console.log(err);
}
}
fetchDogData();
} , [])
return (
<div></div>
)
}
I am trying to fetch data from that api also i used this method but after that i got this message in my screen .....
Module not found: Error: Can't resolve 'zlib' in 'C:\Users\HP\Desktop\React\my-app\node_modules\body-parser\lib'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "zlib": require.resolve("browserify-zlib") }'
- install 'browserify-zlib'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "zlib": false }
Without using cors i got a Cors error something related to header
