sorry this is coming late...
Here's a way to go about it
you can follow this link to get a clearer idea and get an idea of what I initially did wrong
const axios = require("axios")
const shitty_code = async (address, number) => {
this.blue = "blue is bright";
this.purple = async () => {
const one_api_call = await axios.get(`https://one-wierd-api/${address}/${number}`).then((response) => {
return response.data })
}
...
return this;
}
// to call the shitty_code method purple ----------------------
console.log(shitty_code("some_random_address", 12).then(async (e)=> {
const response = await e.purple()
console.log(response)
}))
// it actually worked with the this keyword, yay🎉!
or in your case,
const camera = async () => {
this.a = () => {
console.log('calling ..a');
}
this.b = async () => {
console.log('calling ..b');
}
return this;
}
// calling the function...
camera().then((anything) => {
anything.b();
})
a.var someObject = {}; (function(context) { context.a = ...})(someObject)