Actix Web HTTP Client is not working?

Hi everyone,

I’m trying to get the Actix Web Client to compile, as per the documentation:

use actix_web::{actix, client};

fn main() {
        || client::get("")   // <- Create request builder
            .header("User-Agent", "Actix-web")
            .send()                               // <- Send http request
            .map_err(|_| ())
            .and_then(|response| {                // <- server http response
                println!("Response: {:?}", response);

However, I get an error I cannot seem to work around:

no method named map_err found for type actix_web::client::SendRequest in the current scope

help: items from traits can only be used if the trait is in scope

What am I doing wrong? Is the documention not correct any more?

You need to import Future to use map_err

1 Like

Yes, that solved it! Thank you, perhaps it should be added to the code in the documentation as well?

Yeah, it probably should

Nomally compiler tells you to import Future

I’m using VS Code with RLS - could that be the reason why it didn’t tell anything to me?

Yes, maybe rls isn’t as good as the compiler on error messages

These messages are done on a best effort basis, so the compiler may have just missed Future as a possibility.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.