- 1、js fetch函數怎麼鎐ookie,並且下次請求時帶 cookie 訪問
- 2、javascript的fetch函數?
- 3、jsfetch獲取不到數據時應該怎樣控制顯示報錯信息
最佳答案
fetch默認不發送cookie
如果需要發送cookie,需要指定{credentials: ‘include’}
例如:
fetch(‘/abc/’,{credentials: ‘include’
FormData是一個用於封裝HTTP請求數據的對象,採用鍵值對的方式。
// 實例化一個FormData對象
let formData = new FormData();
// 添加數據
formData.append(‘nameEn’, ‘xxxxx’);
formData.append(‘giftId’,’xxxxx’);
formData.append(‘csrfToken’,’xxxxx’);
// 調用介面
fetch(‘介面地址’, {
method: ‘POST’,
body: formData
})
.then(response = response.json())
.catch(error = console.error(‘Error:’, error))
.then(response = console.log(‘Success:’, response));
能實體Article使用@ManytoOne(fetch=FetchType.EAGER)屬於非操作實體註解指定fetchhql能再寫fetch解決:fetch掉直接Stringhql=”selectcount(ar)fromArticlearleftjoinar.c
原創文章,作者:H48GU,如若轉載,請註明出處:https://www.506064.com/zh-tw/n/126184.html