uniapp post請求

  • 對於 GET 方法,會將數據轉換爲 query string。例如 { name: 'name', age: 18 } 轉換後的結果是 name=name&age=18
  • 對於 POST 方法且 header['content-type'] 爲 application/json 的數據,會進行 JSON 序列化。
  • 對於 POST 方法且 header['content-type'] 爲 application/x-www-form-urlencoded 的數據,會將數據轉換爲 query string。

 

                      uni.request({
					      header: {
					       	      'Content-Type': 'application/x-www-form-urlencoded'  
					       	   }, 
					      url: tha.baseURl+"project_bangding", //僅爲示例,並非真實接口地址。
					       method: 'POST',
					           data: {
					               UserId: user.id
					           },
					       dataType:'json',
					       success: (res) => {
					       	 	var result = JSON.parse(res.data.projectList);
					       		
					           } 
					       }); 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章