Git Product home page Git Product logo

Comments (2)

scleach avatar scleach commented on September 4, 2024

using .str(); is the answer
String responseResult = request->responseText();
Serial.println(responseResult.c_str());

from asynchttprequest.

boblemaire avatar boblemaire commented on September 4, 2024

Serial.println() should work OK with a String argument. In any event responseText() returns the data available at the time of the call and deletes it from the buffer. In your case you are doing it at readyState 4 so it should be all of the data, but consider if you are getting a long response and taking the data with responseText() in an onData callback at readyState 3. You want each call to pickup where the last left off.

So is it possible that you had something like:

String responseResult = request->responseText();
Serial.println(request->responseText());

In that case responseResult would have the response, and the second call to responseText() would return a null string.

I would suggest the the "solution" code:

String responseResult = request->responseText();
Serial.println(responseResult.c_str());

Would work just as well with:

String responseResult = request->responseText();
Serial.println(responseResult);

It really doesn't have anything to do with asyncHTTPrequest. It's work is done in the first line. The printf is overloaded and should work fine with either a String or char* argument.

from asynchttprequest.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.