最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

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

IT培训 admin 4浏览 0评论

从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'});
};

从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. 暂无评论