eva n.
eva n.
NNuxt
Created by eva n. on 9/19/2024 in #❓・help
I can't get api
I am using Vue3 and Nuxt 3. When I click that button, page doesn't refresh it cant fetch again. <v-btn color="primary" @click="refresh">New Quote</v-btn> Here is my script code => `​​`​`​html `const { data: quoteData, refresh, status, error, } = await useFetch("https://zenquotes.io/api/random", { onRequest({ request, options }) { // Optionally set request headers or other options before sending the request options.headers = options.headers || {}; options.headers.authorization = "Bearer someToken"; },` onRequestError({ request, options, error }) { // Handle request errors console.error("Request Error:", error); }, onResponse({ request, response, options }) { // Process the response data, e.g., store token in localStorage console.log("Response Received:", response); if (response._data && response._data.token) { localStorage.setItem("token", response._data.token); } }, onResponseError({ request, response, options }) { // Handle response errors console.error("Response Error:", response); }, }); ​​`​​ ``
2 replies