Using Axios in HarmonyOS JS Framework for Wearables
I'm using HarmonyOs to create a (not lite) Wearable App. I want to use Axios to send requests to my server.
I was able to install the package with npm install axios
and import
it on the page I want to use it.
The problem I'm facing is that the whole axios request seems to be ignored. Here is an example.
import axios from 'axios'
export default {
onButtonClick() {
console.log("AXIOS TEST")
axios.get("https://example.com/test")
.then(result => console.log("AXIOS result " + result))
.catch(error => console.log("AXIOS error " + error))
console.log("AXIOS TEST END")
}
}
I get the AXIOS TEST
and AXIOS TEST END
logs when I click the button but neither the result nor error logs. Neither any other logs related to axios.
I believe I have the needed permissions and I tested this snippet in a node
script and that worked fine.
Am I missing something or can someone please give me a hand?
Solution 1:
As relevant team confirmed, axios is not supported currently, but is being planned.
Therefore, you are advised to preferentially use fetch requests.
For more details,pls kindly refer Docs.