I've got the following code sequence (excerpt), where the error "Error: No object to invoke." occurs - but I cannot figure out, why this happens...
Using latest AHK2 (a100 to a103)
Code: Select all
settings := A_ScriptDir "/settings.json"
str := FileRead(settings)
obj := JSON.Load(str ) ; <-- works correctly
OutputDebug("Settings: " obj2str(obj))
gh := new github(obj.github.name, obj.github.email, obj.github.token)
x := gh.users.getAuthenticatedUser()
obj2 := JSON.Load(x) ; <--- !!! ERROR: No object to invoke occurs
OutputDebug(x)
ExitApp
class github {
class access {
get() {
json :=this.Send("GET",this._url)
return json
}
send(verb,url,data:="",content_type:="application/json"){
this.http.Open(verb,url)
if !(data == "") {
this.http.SetRequestHeader("Content-Typ",content_type)
}
this.http.send(data)
return this.http.ResponseText
}
}
class users {
getAuthenticatedUser() {
this.access.url := "/user"
jsonX := this.access.get()
OutputDebug("< ret: " jsonX) ; <--- jsonX has the correct content
return jsonX
}
}
}
Code: Select all
---------------------------
Demo_Repos.ahk
---------------------------
Error: No object to invoke.
Line#
018: OutputDebug("DBGVIEWCLEAR")
022: settings := A_ScriptDir "/settings.json"
023: str := FileRead(settings)
024: obj := JSON.Load(str )
025: OutputDebug("Settings: " obj2str(obj))
027: gh := new github(obj.github.name, obj.github.email, obj.github.token)
028: x := gh.users.getAuthenticatedUser()
---> 029: obj2 := JSON.Load(x)
030: OutputDebug(x)
031: ExitApp()
032: Exit
033: Exit
033: Exit
The current thread will exit.
---------------------------
OK
---------------------------