How to convert a captcha image to base64 string?


#1

I am using http request (https://docs.nativescript.org/cookbook/http) to get an image.
See the comments below:

http.request({ url: "https://httpbin.org/get", method: "GET" }).then(function (response) {   
    var img = response.content.toImage();  // I find this returns a promise
   
    img.then(function(image){
       // I find image has a method "toBase64String"
       // But do not know how to use it, I find no document for this.
    });
}, function (e) {
});

#2

Is this a question, or a tip? If it’s the former, what is the question? If you found that the image has a method toBase64String - have you tried to call it?


#3

It is a question, as the title says.
I tried to call it. But the result is null.


#4

Did you try . toBase64String("png")? The format param is required.


#5

Solved. Thank you for your link.
The document should contain this.