I was trying to create a dialog using quickblox react-native-sdk. In ANDROID it worked perfectly fine, but in IOS(simulator) it is showing
Error: Request failed: client error (422)
QB.chat
.createDialog({
type: QB.chat.DIALOG_TYPE.CHAT,
occupantsIds: [127929951],
})
.then(function (dialog) {
console.log(dialog);
})
.catch(function (e) {
console.log(e);
});
Thanks in advance
Remove this line:
type: QB.chat.DIALOG_TYPE.CHAT,
Worked in my case. May be QB expects 0 as type for private chat but QB.chat.DIALOG_TYPE.CHAT in enum is type 3 which is not working in our case.
Related
I am currently working on an IoT project which requires service discovery (I am in the Android side). I decided to use react-native-zeroconf and I encountered a problem.
There is a warning Error: Request failed with status code 500 once I called .scan() method.
I have already added permission into the AndroidManifest file. Thank you in advance.
Edit: remove async from function
export function scanmDNS() {
const zeroconf = new Zeroconf();
zeroconf.scan();
const res = zeroconf.getServices();
console.log({ res });
zeroconf.stop();
}
Object {
"res": Object {},
}
Possible Unhandled Promise Rejection (id: 0):
Error: Request failed with status code 500
createError#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:224752:26
settle#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:224742:25
onloadend#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:224619:15
dispatchEvent#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:33843:31
setReadyState#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:32985:29
__didCompleteResponse#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:32783:29
emit#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:4940:42
__callFunction#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:5979:36
http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:5707:31
__guard#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:5933:15
callFunctionReturnFlushedQueue#http://localhost:8081/index.bundle?platform=android&dev=true&minify=false&app=com.doji.dojimobileapplication&modulesOnly=false&runModule=true:5706:21
callFunctionReturnFlushedQueue#[native code]
Possible Unhandled Promise Rejection (id: 1):
There are two ways to handle Promises, since you're using async/await syntax your response should use the await keyword also you are wrapping your response in an object which you shouldn't (without assigning it to a property).
const res = await zeroconf.getServices();
console.log(res)
The other way would be
zeroconf.getServices()
.then((res) => {
console.log(res) //do whatever you want to do with your response here
})
.catch((err) => {
console.log(err) //handle errors here.
}
Not sure if this will solve your problem but hope it leads you to your solution :)
This is the error I get when I try to retrieve data from IBM Watson Assistant using this code, I am in a React Native environment using axios to request and respond:
//ASSISTANT GREETING
init = async session => {
try
{
const _backendEndpoint = 'https://MYAPPLICATIONNAME.mybluemix.net';
const initialPayload = {
input: {
message_type: 'text',
text: '',
},
};
let response = await axios.post(`${_backendEndpoint}/api/message`, {
...initialPayload,
...session,
});
this.setState({ userSession: session });
this.setState({ text: response.data.output.generic[0].text });
this.setState({ userPayload: response.data });
}
catch (err)
{
console.log('Failed to retrive data from Watson API', err);
}
};
Did IBM Change their codebase or something so you can no longer get requests? I am at a loss.
Thanks
If you are expecting https://MYAPPLICATIONNAME.mybluemix.net to be your instance of Watson Assistant then this is not going to work. The endpoint should look something like https://api.us-south.assistant.watson.cloud.ibm.com
see the API documentation for a list of endpoints for the regions- https://cloud.ibm.com/apidocs/assistant/assistant-v2?code=python#service-endpoint
The endpoint that you use will depend on which region you have your Watson Assistant.
You also need to authenticate with the server, which isn't apparent in your code snippet.
If, however, https://MYAPPLICATIONNAME.mybluemix.net is your backend application server, then I expect it should have an API endpoint defined for /api/message, where your error is occurring. Please share the code for your /api/message endpoint. If you don't have any, then that is why you are getting a 500 error.
I'm currently building a react app for face detection. I use the code below to implement the Clarifai Face Detection API but I get a 404 error instead of a response. Is my syntax wrong?
const Clarifai = require("clarifai");
const app = new Clarifai.App({
apiKey: "my-api-key",
});
app.models
.predict(
"45fb9a671625463fa646c3523a3087d5",
this.state.input
)
.then(
function (response) {
// do something with response
console.log(response);
},
function (err) {
// there was an error
}
);
At first, please use the updated gRPC Node client: https://www.npmjs.com/package/clarifai-nodejs-grpc
(Clarifai has deprecated the REST clients in 2020)
Let me know if that solved your issue.
I'm new to react-native, I want to fetch some data from my local laravel server, but I fire the mobx action I get the following errors:
Network Error
[Unhandled promise rejection: Error: Network Error]
This is my mobx action (I'm using flow, similar to async/await), I get 'fire' log but after that I get the error above:
listProducts = flow( function*(payload)
{
console.log('fire');
try
{
let response = yield axios.get('http://192.168.1.39:8000/api/products', { params: payload });
this.posts = response.data;
this.pagination = response.data.pagination;
console.log(response);
//return response;
}
catch (error)
{
console.error(error);
throw error;
}
});
As you can see I'm using my local IP instead of localhost, I'm also testing my app on my android device using EXPO connected to the same network as my dev laptop.
Ciao, I can't see errors on your code. Try to follow this guide to handle Unhandled promise rejection. Could help you to find a clue.
In brief the guide suggest to use axios interceptors:
axios.interceptors.response.use(
response => response,
error => {}
)
I'm using the SDK client in React Native to add chat to my app using Twilio Programmable Chat. The code to send a message is below:
client.sendMessage(message.text)
.catch(err => console.log(err));
I am getting an error back in my console which says:
Error: Can't add command: (status: 0, code: 0)
at session.js:173
at tryCallOne (core.js:37)
at core.js:123
at JSTimers.js:294
at _callTimer (JSTimers.js:151)
at _callImmediatesPass (JSTimers.js:199)
at Object.callImmediates (JSTimers.js:463)
at MessageQueue.__callImmediates (MessageQueue.js:316)
at MessageQueue.js:136
at MessageQueue.__guard (MessageQueue.js:291)
I'm catching it so it's not causing any problems in my actual app but it would be great to understand that's causing it and how to fix it.
Note: The message is sending and all functionality looks to be fine.
Thanks for any help
I was able to get rid of this issue on my end. It was due to an improper Promise chain with my leaveChannel() method. Since resolving this I have not had any issues with the add command error, which I believe was caused by the room not properly disconnecting. Below is my method for disconnect if it helps. Let me know how you make out.
leaveChannel() {
return new Promise((resolve, reject) => {
if (this.channel) {
this.channel.removeAllListeners();
this.channel
.leave()
.then((leftChannel: Channel) => {
console.log("Left chat channel: " + leftChannel.uniqueName);
store.dispatch(chatSetState(ConnectionStateEnum.DISCONNECTED));
resolve();
})
.catch((error: any) => {
console.log("leaveChannel(): ", error);
this.channel = null;
reject(error);
});
} else {
console.log("Not currently in a channel.");
}
});}