Hello,
by consuming a web service REST, I encountered this new error message :
Response with status: 0 for URL: null
Here you have the links to my codes :
app.module.ts
home-service.ts
home.ts
So, I understood my problem was related to the CORS thing, so, by reading this page, I ran the npm install cors command, I got these messages :
npm WARN saveError ENOENT: no such file or directory, open ‘C:\Windows\system32
package.json’ npm WARN enoent ENOENT: no such file or directory, open ‘C:\Windows\system32\package.json’
npm WARN system32 No description
npm WARN system32 No repository field.
npm WARN system32 No README data
npm WARN system32 No license field.
- cors@2.8.4
updated 1 package in 5.785s
Strangely, the C:\Windows\system32\package.json file didn’t exist and I found the file C:\Windows\system32\package-lock.json, so, I made a copy of this file and i renamed it into package.json.
By running then the npm install cors command, these messages appeared :
npm WARN system32 No description
npm WARN system32 No repository field.
npm WARN system32 No license field.
- cors@2.8.4
removed 1 package and updated 1 package in 4.363s
Maybe it’s useless but here you have the content of my package-lock.json file:
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"@types/node": {
"integrity": "sha512-R+LdMJHJQwRd/Ca0Nr5KnwbSWHxTD3DWz4ivqoPeNH+YPcuirMWK+Ti9Mx32jOecmPhHOCd+6CefU5e1eVq2Ew==",
"resolved": "https://registry.npmjs.org/@types/node/-/node-8.0.31.tgz",
"version": "8.0.31"
},
"cors": "^2.8.4",
"object-assign": {
"integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=",
"resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz",
"version": "4.1.1"
},
"vary": {
"integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=",
"resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz",
"version": "1.1.2"
}
}
}
What else should I do to consume my web service? The web service I’m consuming runs on postman, I even took a screenshot of it.
Thanks