Я впервые использую Angular. У меня есть приложение Angular 4, которое работает на сервере REST, сгенерированном Hyperledger Composer . Я пытаюсь внести некоторые изменения в приложение, например, добавить несколько вызовов REST.
Я хотел бы вызвать метод REST:
POST / кошелек / {имя} / setDefault
![The definition of the method](https://i.stack.imgur.com/CMW67.png)
Но я не знаю, как передать имя параметра.
Это содержимое файлов, используемых для POST CALL:
home.component.html
<div class="container">
<button (click)="setDefaultWalletCard('hatcher1');" type="submit" class="btn btn-success" value="Refresh Page" onClick="setTimeout(window.location.reload.bind(window.location), 2000);" data-dismiss="modal">Confirm</button>
</div>
home.component.ts
import { Component } from '@angular/core';
import { DataService } from './home.service';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.css'],
providers: [DataService]
})
export class HomeComponent {
constructor (private dataService: DataService){
};
public setDefaultWalletCard(card: string) {
return this.dataService.setDefaultCard(card);
}
}
home.service.ts
import { Injectable } from '@angular/core';
import { Http, Response, Headers } from '@angular/http';
@Injectable()
export class DataService{
private resolveSuffix: string = '?resolve=true';
private actionUrl: string;
private headers: Headers;
constructor(private http: Http) {
this.actionUrl = '/api/';
this.headers = new Headers();
this.headers.append('Content-Type', 'application/json');
this.headers.append('Accept', 'application/json');
}
public setDefaultCard(cardName){
var data = new FormData();
data.append("", "");
return this.http.post('localhost:3000/api/wallet/'+cardName+'/setDefault', data, {withCredentials: true});
}
}
Я получаю ошибку:
Ответ со статусом: 0 для URL: ноль
Можете ли вы помочь мне, пожалуйста? Спасибо