I get error
/**
* API is not available.
*
* This means the API can't be used right now because:
* - it is currently missing a prerequisite, such as network connectivity
* - it requires a particular platform or browser version
I created Capacitor App by existing Nuxt.js project and use dist folder which is generated by executing nuxt generate. When I run App, API request respond html file below
var ExceptionCode;
(function (ExceptionCode) {
/**
* API is not implemented.
*
* This usually means the API can't be used because it is not implemented for
* the current platform.
*/
ExceptionCode["Unimplemented"] = "UNIMPLEMENTED";
/**
* API is not available.
*
* This means the API can't be used right now because:
* - it is currently missing a prerequisite, such as network connectivity
* - it requires a particular platform or browser version
I have backend at /server/api/XYZ.js
for example /server/api/proxy.js
import { defineEventHandler, getQuery } from 'h3';
import axios from 'axios';
export default defineEventHandler(async (event) => {
const { url } = getQuery(event);
if (!url) {
event.res.statusCode = 400;
return { error: 'Missing URL parameter' };
}
try {
const response = await axios.get(url, {
headers: {
'User-Agent': 'Mozilla/5.0',
},`your text`
});
return response.data;
} catch (error) {
console.error('Error fetching the URL:', error);
event.res.statusCode = 500;
return { error: 'Failed to fetch the URL' };
}
});
it returns me html of desired page and i use it like
const fetchShops = async () => {
try {
isLoading.value = true;
const response = await axios.get('/api/proxy', {
params: {
url: 'XYZ.com',
},
});
return response.data;
} catch (error) {
isLoading.value = false;
console.error('Error fetching shops:', error);
}
}
In android studio in logcat i get log:
Handling local request: http://localhost:3000/api/proxy?url=XYZ.com
i don’t get any data from backend. How can i fix it?