我正在将我的应用程序更新为Angular 9 CLI,并将我的所有NPM软件包更新为最新版本。但是,当我尝试进行GET调用以将数据加载到页面加载时,页面中断,服务器返回400错误。该端点调用中断:
@Effect()
getAllData$ = this.action$.pipe(
ofType<DataAction>(DATA_ACTION_TYPES.GET_ALL_DATA),
switchMap(() => {
return this.dataservice.getAllData().pipe(
map(data => {
const payload = new DataPayload();
payload.data = data;
return new GottenAllDataAction(data);
})
);
})
);
public getAllData(): Observable<any[]> {
// code hits the dataEndpoint
return this.httpClient
.get(this.dataEndpoint)
.pipe(map(response => plainToClass(DataV2, response as Object[], { groups: ['get'] })));
}
在“网络”标签中,此响应出现400错误:
这是GET调用中我的400控制台错误的开始:
这是我的package.json:
"dependencies": {
"@angular/animations": "9.1.6",
"@angular/cdk": "9.2.3",
"@angular/common": "9.1.6",
"@angular/compiler": "9.1.6",
"@angular/core": "9.1.6",
"@angular/flex-layout": "~9.0.0-beta.29",
"@angular/forms": "9.1.6",
"@angular/material": "9.2.3",
"@angular/platform-browser": "9.1.6",
"@angular/platform-browser-dynamic": "9.1.6",
"@angular/router": "9.1.6",
"@auth0/angular-jwt": "^4.0.0",
"@ngrx/effects": "~9.1.2",
"@ngrx/router-store": "~9.1.2",
"@ngrx/store": "~9.1.2",
"@ngrx/store-devtools": "~9.1.2",
"@nrwl/nx": "6.3.1",
"class-transformer": "0.1.9",
"classlist.js": "^1.1.20150312",
"core-js": "~3.6.5",
"es6-shim": "^0.35.5",
"file-saver": "^2.0.2",
"hammerjs": "2.0.8",
"highcharts": "~8.1.0",
"moment": "~2.25.3",
"ng2-file-upload": "^1.4.0",
"ngx-toastr": "^12.0.1",
"ramda": "^0.27.0",
"reflect-metadata": "~0.1.13",
"rxjs": "~6.5.5",
"rxjs-compat": "~6.5.5",
"tachyons-sass": "^4.9.5",
"tslib": "^1.11.2",
"typedjson": "^1.5.1",
"zone.js": "~0.10.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.901.5",
"@angular-devkit/core": "9.1.5",
"@angular-devkit/schematics": "9.1.5",
"@angular/cli": "9.1.5",
"@angular/compiler-cli": "9.1.6",
"@angular/language-service": "9.1.6",
"@nrwl/schematics": "8.12.11",
"@schematics/angular": "9.1.3",
"@types/highcharts": "5.0.4",
"@types/jasmine": "^3.5.10",
"@types/jasminewd2": "~2.0.8",
"@types/node": "^13.13.4",
"codelyzer": "^5.2.2",
"fibers": "^3.1.0",
"html-webpack-plugin": "^4.2.1",
"jasmine-core": "^3.5.0",
"jasmine-marbles": "0.3.1",
"jasmine-spec-reporter": "^5.0.2",
"karma": "~5.0.5",
"karma-chrome-launcher": "^3.1.0",
"karma-cli": "^2.0.0",
"karma-coverage-istanbul-reporter": "^3.0.2",
"karma-jasmine": "^3.1.1",
"karma-jasmine-html-reporter": "^1.5.3",
"ng-mocks": "^9.3.0",
"node-sass": "^4.14.0",
"prettier": "^1.18.2",
"protractor": "^5.4.4",
"remote-redux-devtools": "^0.5.16",
"ts-node": "~8.10.1",
"tslint": "~6.1.2",
"typescript": "~3.8.3"
}
[在Angular 8中一切正常。此错误仅发生在我尝试更新至最新Angular 9的当前分支中。但是我不确定前端问题如何导致我看到的错误。 NPM软件包更新之一可能会出问题吗?
感谢您的任何帮助。
您能否为angular8和angular 9的两个版本共享您的get调用标头?我认为您的GET调用的标头配置不正确