NativeScript / sample-Groceries

:green_apple: :pineapple: :strawberry: A NativeScript-built iOS and Android app for managing grocery lists
Apache License 2.0
485 stars 345 forks source link

getCommonHeaders is not defined #299

Closed zhangsuimi closed 6 years ago

zhangsuimi commented 6 years ago

I paste this code from the official website ,but something goes wrong,what should I do?I just started to learn this,please help me !thank you! image

this is the related code:

exports.signIn = function(){
    user.login();
};

this is the console log:

ReferenceError: getCommonHeaders is not defined
    at ObservableFromObject.User.viewModel.login (file:///data/data/org.nativescript.Groceries/files/app/shared/view-models/user-view-model.js:20:22)
    at Object.exports.signIn [as callback] (file:///data/data/org.nativescript.Groceries/files/app/views/login/login.js:18:7)
    at Button.Observable.notify (file:///data/data/org.nativescript.Groceries/files/app/tns_modules/tns-core-modules/data/observable/observable.js:103:23)
    at Button.Observable._emit (file:///data/data/org.nativescript.Groceries/files/app/tns_modules/tns-core-modules/data/observable/observable.js:120:18)
    at Object.ClickListenerImpl.onClick (file:///data/data/org.nativescript.Groceries/files/app/tns_modules/tns-core-modules/ui/button/button.js:22:24)
narchontis commented 6 years ago

There refactored it. File called: user-view-model.js should have 3 functions .... f() User(info) f() getCommonHeaders() f() handleErrors(response)

function getCommonHeaders() {
    return {
        "Content-Type": "application/json",
        "Authorization": config.appUserHeader
    }
}

This will fix your f() issue.... But I, in my case am not getting a response from my query.