如何处理通过url发送的问号?

我正在使用axios向我的数据库发送一些字符串。我现在发送的东西是

1: Header -> the value can be anything such as "Who is Michael Scott?"
2: Body -> the value can be anything such as "Why do people quote Michael Scott a lot?"

使用的axios命令im是:

  axios.post(`/post/create/${Header}/${Body}`).then(result => {
    alert("Your post has been added!")
    console.log("Posted")
  }).catch(function (error) {
      // Output error
      console.log(error);
  });

url (地址栏)中的输出为:

http://my_ip_here:3000/api/v1/post/create/Who%20is%20Michael%20Scott?/Why%20do%20people%20quote%20Michael%20Scott%20a%20lot?/

因为这个问号,我最终得到了一个404。我的问题是,如何处理作为url参数传递的字符串中的问号?

如果有帮助,我正在使用React.js、Axios和Mysql。

转载请注明出处:http://www.yhsswkj.com/article/20230526/1285949.html