fetch(baseURL + '/api/v1/login', {
method: 'POST',
body: JSON.stringify(body),
headers: new Headers({
'Content-Type': 'application/json'
})
}).then(function (res) {
return res.json()
}).then(function (response) {
console.log(response.token)
return response.token
})
//上面是登入後取得token
fetch(baseURL + '/api/v1/user/info', {
method: 'GET',
headers: {
'Authorization': `Bearer ${token}`
},
}).then(function (response) {
console.log(response)
})
//下面是需要token才能取得網站資料
想請問上面已經可以console.log跑出token了
那要怎麼把token放進去下面的fetch呢?
感謝!