Uzyxen
Uzyxen
NNuxt
Created by Uzyxen on 11/17/2024 in #❓・help
middleware
@kapa.ai I used method 3. And it works. I have question. Is it a good idea to fetch initial JWT token in plugin? How many times api will be called?
10 replies
NNuxt
Created by Uzyxen on 11/4/2024 in #❓・help
useFetch server-side
I'm getting an error "hydration text content mismatch on". I have to send useFetch requests in a loop and add responses to the array. For a while it's good and array has few different elements but after 1-2 seconds it's the same code:
const { data: images } = await useFetch(`http://localhost:5271/api/image/uploadGalleryImages/${id}`, {
responseType: 'json',
method: 'get',
headers: {
'Content-Type': 'application/json',
}
});

const files = ref([]);
const formData = new FormData();
const imageSrc = ref(null); // Ustawienie na null na początku

for (const image of images.value) {
const { data: singleImage } = await useFetch('http://localhost:5271/api/image/uploadGallerySingleImage', {
responseType: 'arrayBuffer',
method: 'post',
body: JSON.stringify({
ImagePath: image.imageSource
}),
headers: {
'Content-Type': 'application/json',
},
server: true,
lazy: false
});

console.log(singleImage);

//console.log(singleImage);

const mimeType = "image/png";
const blob = new Blob([singleImage.value], { type: mimeType });
const file = new File([blob], image.imageSource.split('/').pop(), { type: mimeType });

//console.log(file);

//console.log(singleImage);
files.value.push(file);
}
const { data: images } = await useFetch(`http://localhost:5271/api/image/uploadGalleryImages/${id}`, {
responseType: 'json',
method: 'get',
headers: {
'Content-Type': 'application/json',
}
});

const files = ref([]);
const formData = new FormData();
const imageSrc = ref(null); // Ustawienie na null na początku

for (const image of images.value) {
const { data: singleImage } = await useFetch('http://localhost:5271/api/image/uploadGallerySingleImage', {
responseType: 'arrayBuffer',
method: 'post',
body: JSON.stringify({
ImagePath: image.imageSource
}),
headers: {
'Content-Type': 'application/json',
},
server: true,
lazy: false
});

console.log(singleImage);

//console.log(singleImage);

const mimeType = "image/png";
const blob = new Blob([singleImage.value], { type: mimeType });
const file = new File([blob], image.imageSource.split('/').pop(), { type: mimeType });

//console.log(file);

//console.log(singleImage);
files.value.push(file);
}
@kapa.ai
10 replies
NNuxt
Created by Uzyxen on 11/3/2024 in #❓・help
$fetch from client vs from server
@kapa.ai but I allowed all methods and headers: builder.Services.AddCors(options => { options.AddPolicy("AllowNuxtApp", builder => builder .WithOrigins("http://localhost:3000") // Nuxt app URL .AllowAnyMethod() .AllowAnyHeader() .AllowCredentials()); });
11 replies
NNuxt
Created by Uzyxen on 11/3/2024 in #❓・help
$fetch from client vs from server
No description
11 replies