AlamoFire doesn't appear to be doing anything

Eric_WVGG

I am attempting to write a simple scraper with AlamoFire, vis a vis a server-side Vapor back end. AlamoFire appears to be initiated properly, but I'm not getting any action from the callback handler.

import Routing
import Vapor
import Alamofire

public func routes(_ router: Router) throws {
    router.get("scrape") { req -> String in
        let stuff = Stuff(id: nil, sourcecode: "This saves to the database.")
        stuff.save(on: req)
        let q = Alamofire.request("http://sigh-fi.com/test.txt").responseString { response in

            // None of this prints to the terminal.
            print("Success: \(response.result.isSuccess)")
            print("Request: \(String(describing: response.response))")
            print("Result: \(String(describing: response.result))")
            print("String: \(String(describing: response.result.value))")

            // ideally I'd like to run...
            // let morestuff = Stuff(id: nil, sourcecode: response.result.value)
            let morestuff = Stuff(id: nil, sourcecode: "This doesn't save to the database, so I'm not even getting that far.")
            morestuff.save(on: req)
        }
        print(q) // prints "GET http://sigh-fi.com/test.txt" as expected
        return "okay"
    }
}

Unfortunately I can't tell if this is a Vapor problem, an Alamofire or Swift problem. Any suggestions would be greatly appreciated.

Eric_WVGG

So it turns out that Vapor has its own HTTP client library, and it seems to work just fine. Still unsure why Alamofire fell apart, but it's moot.

Thank you for your assistance, Nick.

https://docs.vapor.codes/3.0/http/client/

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

toFixed Isn't Doing Anything

分類Dev

App icon doesn't appear

分類Dev

Why this doesn't appear to be initialized

分類Dev

postgresql trigger with dblink doesn't return anything

分類Dev

express-validator doesn't do anything

分類Dev

Array doesn't print anything on executing code

分類Dev

Grunt Smoosher doesn't do anything

分類Dev

PHP SimpleXML doesn't output anything

分類Dev

Collectionview doesn't show anything during runtime

分類Dev

Why doesn't ZIP Compression compress anything?

分類Dev

btrfs filesystem resize doesn't do anything

分類Dev

wget not doing anything

分類Dev

Inserted formula not doing anything

分類Dev

int 80 doesn't appear in assembly code

分類Dev

Android-Notification doesn't appear

分類Dev

Javascript code doesn't appear on the page

分類Dev

correct ngSwitchCase doesn't make paragraph appear

分類Dev

Ckeditor doesn't appear at foreign countries

分類Dev

IconMenu doesn't appear in material-ui

分類Dev

the android device is connected to the wamp server but doesn't show anything in listview

分類Dev

"dnvm" command inside Package Console Manager doesn't show anything

分類Dev

Grunt + Babel successfully runs but doesn't do anything

分類Dev

Angular 2 Firebase Observable to promise doesn't return anything

分類Dev

Why doesn't mongoose's .find({}) method do anything at all?

分類Dev

Extending tsconfig.json file doesn't seem to extend anything

分類Dev

Python script converted to exe doesn´t do anything

分類Dev

VS Code Debugger - Felix Becker - Debugger doesn't hit anything

分類Dev

Why doesn't anything in my if-else work?

分類Dev

logstash agent doesn't output anything in verbose mode

Related 関連記事

ホットタグ

アーカイブ