I am trying to send an object from addon to node but get:
no matching function for call to ‘Napi::Object::New(Napi::Env&, Napi::Object&)’
.
How can I achieve that.
Any help will be appreciated. Below is the code in question.
std::shared_ptr<ThreadSafeCallback> callback = NULL;
// declared globally
callback = std::make_shared<ThreadSafeCallback> (info[0].As<Function>());
std::thread([callback]
{
try
{
callback->call([result, data](Napi::Env env, std::vector<napi_value>& args){
const unsigned char* t = reinterpret_cast<const unsigned char *>( "123" );
Object obj = Object::New(env);
obj.Set("name", "world");
obj.Set("frame", (char *)t);
args = { env.Undefined(), Napi::Object::New(env, obj) }; // faile here
// would like to have {"name": test, frame: buf}
});
}
}).detach();
Just changed Napi::Object::New to Napi::Object::Value. Its in the docs, but somehow i missed it.