最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

从Angular 8发布到Node.JS的最佳方法是什么

运维笔记admin9浏览0评论

从Angular 8发布到Node.JS的最佳方法是什么

从Angular 8发布到Node.JS的最佳方法是什么

我在使用此功能时会遇到一些麻烦。到目前为止,我使用GET方法,现在我需要将一些数据发布到服务器。

这是一个GET请求:

getReports(userID) {
    return this.http.request<Reports[]>('GET', this.baseUrl + this.REPORTS_API + '/' +
     this.USER_API + '/' + userID, { responseType: 'json' });
}

现在我需要发布数据

createNewReport(companyID, type, year){
    return this.http.request<[]>('POST', this.baseUrl + this.REPORTS_API, { responseType: 'json'});
}

我应该将数据放在哪里?

回答如下:

您需要将数据传递为,

createNewReport(companyID, type, year){
    const data = JSON.stringify({companyId: companyID, type: type});
    return this.http.post(this.baseUrl + this.REPORTS_API, data , { responseType: 'json'});
};
发布评论

评论列表(0)

  1. 暂无评论