I am following along with the above article trying to access a string in an object that is passed to a C++ node addon function. My function is below but I am unable to get it the addon to compile. When I do I get the error:
../addon.cpp:239:26: error: no viable conversion from 'MaybeLocal<v8::Value>' (aka 'v8::MaybeLocal<v8::Value>') to 'v8::Local<v8::Value>'
v8::Local<v8::Value> pwdValue = Nan::Get(obj, pwdProp);
^ ~~~~~~~~~~~~~~~~~~~~~~
Any ideas on how I might resolve this error? Thanks
NAN_METHOD(init) {
v8::Local<v8::Object> obj = info[0]->ToObject();
v8::Local<v8::String> pwdProp = Nan::New("PWD").ToLocalChecked();
std::string pwd = "";
if (Nan::HasOwnProperty(obj, pwdProp).FromJust()) {
v8::Local<v8::Value> pwdValue = Nan::Get(obj, pwdProp);
pwd = std::string(*Nan::Utf8String(pwdValue->ToString()));
}
std::cout << pwd << std::endl;
}