hi我想从后端发送的json中获取用户的照片,但是无法获取照片将显示在 Postman “imageName”中:“0fa6ee43-adac-4ee6-ae21-a84ff6cef891.jpg”,这是来自我后端的图像
const userToken = localStorage.getItem("token");
AxiosBaseUrl.get("url", {
headers: {
Authorization: `Bearer ${userToken}`,
},
}).then((response) => {
const image = new File([response.data.imageName], 'profileName', {type: 'image/jpeg'});
console.log(image);
setProfileImage(image);
setEmail(response.data.email);
setFullName(response.data.fullName);
setGender(response.data.gender);
setPhoneNumber(response.data.phoneNumber);
console.log(response);
});
<img
accept="image/*"
src={URL.createObjectURL(profileImage)}
alt="profile_image"
/>
感谢大家
1条答案
按热度按时间bzzcjhmw1#
我探索了许多途径,包括:斑点