AlamofireObjectMapping Error: Cannot call GET
<p><strong>UPDATE</strong></p>

<p>My POST request in Login.swift returns values that I would like mapped to the variables in Particulars.swift (E.g. the API token) and by extension, written to realm. How do I go about doing so?</p>

<p>My Login.swift code:</p>

<pre><code>import Foundation
import Alamofire
import SwiftyJSON
import RealmSwift
import ObjectMapper
import AlamofireObjectMapper


class Login {


init(userName: String, passWord: String) {
    Data.sharedInstance.userName = userName
    Data.sharedInstance.passWord = passWord
}

// call this method to login
func getRequest() {

    Alamofire.request(.POST, Data.todoEndpoint, parameters: ["username": Data.sharedInstance.userName!, "password": Data.sharedInstance.passWord!])
        .responseJSON { response in

            if let result = response.result.value
            {
                let value = JSON(result)

                    if let api_key = value["api_token"].string
                    {
                        print("The token is " + api_key)

                    }

                    else
                    {
                        print("error parsing api token")
                    }

            }
            else
            {
                print("JSON data is nil.")
            }


    }

}


}
</code></pre>

<hr>

<p>I am trying to map my JSON requests to Realm but I keep being thrown this error</p>

<blockquote>
  <p>Generic parameter 'T' could not be inferred</p>
</blockquote>

<p>This is what I am looking for: (all in separate files)</p>

<p>send GET requests -> store in realm/ create new object if it does not exist/ update object</p>

<p>How can I fix it?</p>

<p><a href="https://i.stack.imgur.com/XnuVH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XnuVH.png" alt="Error calling GET method"></a></p>

<p><strong>Code to call GET request</strong>  (full code here <a href="https://codeshare.io/l4cEQ" rel="nofollow noreferrer">https://codeshare.io/l4cEQ</a>)</p>

<pre><code>FetchData.get(Particulars.self, success: {
                            print("success!!!")
                    }) {
                         print("fail!!!")
                    }
</code></pre>

<p><strong>Code to process GET request</strong></p>

<pre><code>import Foundation
import Alamofire
import ObjectMapper
import AlamofireObjectMapper
import RealmSwift

class FetchData {
static func get &lt;T:Object where T:Mappable,T:Meta&gt; (type:T.Type,success:()-&gt;Void,fail:()-&gt;Void)-&gt;Void {
    Alamofire.request(Method.GET, type.url())
        .responseArray { (response: Response&lt;[T], NSError&gt;) in
            switch response.result {
            case .Success:
                let items = response.result.value
                if let items = items {
                    let realm = try! Realm()
                    try! realm.write {
                        for item in items {
                            realm.add(item, update: true)
                        }
                    }
                    success()
                }
            case .Failure(_):
                fail()
                break
            }
    }
}
}
</code></pre>

<p><strong>Code to map objects</strong> (Particulars.swift)</p>

<pre><code>import Foundation
import RealmSwift
import ObjectMapper

protocol Meta {
static func url()-&gt;String
}

class Particulars: Object, Mappable {
dynamic var name = ""
dynamic var email = ""
dynamic var id = 0
dynamic var profilePicture = ""
dynamic var username = ""
dynamic var apiToken = ""

override static func primaryKey() -&gt; String? {
    return "id"
}

//Impl. of Mappable protocol
required convenience init?(_ map: Map) {
    self.init()
}

func mapping(map: Map) {
    id    &lt;- map["id"]
    name &lt;- map["name"]
    email &lt;- map["email"]
    profilePicture &lt;- map["profile_picture"]
    username &lt;- map["username"]
    apiToken &lt;- map["api_token"]
}

//Impl. of Meta protocol
static func url()-&gt;String {
    return "https://bitbucket.org/hyphe/blog-examples/raw/master/fetchData/demoapi/books"
}

}
</code></pre>