I have a unique edge case. I am building a hybrid app, and using axios to send commands to an IOT device.
The problem is the IOT device is not supporting the OPTIONS header. If I send a plain axios.post, I can see a response in the network tab. But if I put in async/await function the request hangs in pending, I assume because its waiting for response to options.
I double the JS itself is helpful, but I include it for good measure: This works:
const auth = { username: 'admin', password: 'rLVeWja2zf' }
axios.post('http://192.168.4.1/cmd', { "cmd": "{\"cmd\": {\"uuid\": \"0861F\", \"value\": \"1fa4ffd118219f4ed1bcb27ef8e5e71d\"}}" }, { auth} )
this doesn't:
const init = async() => {
const auth = { username: 'admin', password: 'rLVeWja2zf' }
axios.post('http://192.168.4.1/cmd', { "cmd": "{\"cmd\": {\"uuid\": \"0861F\", \"value\": \"1fa4ffd118219f4ed1bcb27ef8e5e71d\"}}" }, { auth} )
.then(response => {
const users = response.data.data;
console.log(`GET list users`, users);
})
.catch(error => console.error(error));
};
init();