I recently updated from Angular 4 to 9. I did the following:
rxjs
(added pipes where necessary, removed concat)HttpModule
(deprecated) to eliminate errors relating to 'cannot find HTTP' errors and get my project back on trackI am now at the point where running ng build / ng serve
does not throw any errors, and I am able to visit local host and get my landing page. However, using my old login form does not work. I keep getting a CORS
error, though I have the following headers set in express
:
app.use(function(req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Headers', 'Origin, X-Requested-With, Content-Type, Accept');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, PUT, PATCH, DELETE, OPTIONS');
next();
});
Relevant Package Details: "@angular/core": "~9.1.4" <-- all angular components are at this point, "@angular/common": "~9.1.4", "@angular/http": "^7.2.16", "express": "^4.17.1"
My questions are:
HTTP module
as I am trying to do? If anyone has had success with it, were there any configuration changes / was it plug and play?HTTP module
rather than updating to httpClient? httpClientModule
, is there a tool/utility that can be used to make this update easier?It is not so easy to upgrade 5 major versions at one shot. You should better follow the updated guide
As for the HttpModule
, it is deprecated and removed after v7. It is much easier to upgrade to new HttpClientModule
than trying to make something removed working.
For people who are coming across this, here was how I ended up resolving my upgrade problems:
I wish there was an easier way to do it because this was a time consuming process. However, in the end it worked out and I was able to upgrade the entire project.
I know this question has been downvoted - I'm not sure why, especially since it has had over 1,000 views. Hopefully my answer helps anyone else struggling with this issue.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.