Reputation: 691
In my asp.net core 3.1 I have method which I am returning back aws intance type list and I am consuming api in my angular 8 project.
When I use postman I am getting back json result as
[
"c5n.4xlarge",
"m2.2xlarge",
"t3.xlarge",
"m5dn.8xlarge",
..........
]
But in network tab in chrome I am getting response back
And when I try to post (it works in backend) It throws error
Input string was not in correct format
I see it does not grab value and sets to undefined. How to make json result similar to postman result not numbered. No idea that is the reason or not. But in response section it is normal json. Maybe it is multiple arrays that is the reason.
P.S. Also looked another topics about Input string was not in correct format but it was related with integer issue but in my case I need just string
My service: // it is also similar method for opentack and it works fine
createAws(model: any, projectId: number, instanceType?: any) {
return this.http.post(`${this.baseUrl}servers/${projectId}?i
instanceType=${instanceType}`, model);
}
My component: //
selectInstanceHandler(event: any){
this.selectedInstance = event.target.value;
}
createAws(instanceType: any){
this.subs.add(this.cvmService.createAws(this.model,this.projectId,instanceType).subscribe(
x => {
this.model = x;
this.alertify.success("successfully added new Server");
},
error => {
this.alertify.error("\n" + error);
}
))
}
My html:
<div class="row" *ngIf="type == 'AWS'">
<div class="col-3 mt-3 labelText">
<span class="spanText">Aws Instance Type</span>
</div>
<div class="col-9">
<mat-form-field class="example-full-width">
<mat-label>Please select intance type</mat-label>
<select matNativeControl required name="awsInstanceType"
[(ngModel)]="model.awsInstanceType"
(change)="selectInstanceHandler($event)">
<option value="-1" disabled> </option>
<option *ngFor="let item of aws">
{{ item }}
</option>
</select>
</mat-form-field>
</div>
</div>
Example in postman which works:
{{url}}/api/servers/22?instanceType=r5a.large
Upvotes: 1
Views: 354
Reputation: 2377
The result is not numbered, it is just chrome's way of formatting data to make it easy to read. That is why it is known as preview tab.
Check the response tab, the response is just the array of strings (i.e. not numbered)
Upvotes: 2