将HTML字符串发送到节点服务器

时间:2018-04-07 07:57:54

标签: node.js rest api

我想将HTML字符串数据发送到nodjs服务器。但是,当api方法没有拿起数据字符串时。当我发送没有html标签的纯文本字符串时它工作正常。在发送到服务器之前,我是否需要对html字符串进行编码?

HTML data string looks like this: <p> Some text </p>

Pure data string looks like this: Some text

谢谢。

客户端代码:失败。

 pushData(value: any) {
  return this.httpClient.post('http://localhost:3030/api/postdata/' + 'This is a test', {observe: 'body'}).subscribe(res => {

  }, err => {

  });
  }

客户端代码:已通过

 pushData(value: any) {
  return this.httpClient.post('http://localhost:3030/api/postdata/' + 'This is a test', {observe: 'body'}).subscribe(res => {

  }, err => {

  });
  }

服务器端代码:

app.post('api/postdata/:data',function(req,res){
const stringData = req.data;
}

0 个答案:

没有答案
相关问题