0
TypeError: _jquery2.default.ajax is not a function
at Object.login (/Users/Vinit/Documents/Bookr/src/util/uber/auth_api.js:19:12)
at /Users/Vinit/Documents/Bookr/server.js:22:21
at Layer.handle [as handle_request] (/Users/Vinit/Documents/Bookr/node_modules/express/lib/router/layer.js:95:5)
at next (/Users/Vinit/Documents/Bookr/node_modules/express/lib/router/route.js:131:13)
at Route.dispatch (/Users/Vinit/Documents/Bookr/node_modules/express/lib/router/route.js:112:3)
at Layer.handle [as handle_request] (/Users/Vinit/Documents/Bookr/node_modules/express/lib/router/layer.js:95:5)
at /Users/Vinit/Documents/Bookr/node_modules/express/lib/router/index.js:277:22
at Function.process_params (/Users/Vinit/Documents/Bookr/node_modules/express/lib/router/index.js:330:12)
at next (/Users/Vinit/Documents/Bookr/node_modules/express/lib/router/index.js:271:10)
at /Users/Vinit/Documents/Bookr/server.js:14:3
これは私が受け取っているエラーです。私はユーバーのAPIをユーザーにしようとしています。私は認証コードを受け取りましたが、アクセストークンのためにポストリクエストを交換する必要があります。私のサーバーコードは次のとおりです。TypeError:_jquery2.default.ajaxは関数ではありません
const app = express();
app.use((req, res, next) => {
res.header('Access-Control-Allow-Origin', "http://localhost:3000");
res.header('Access-Control-Allow-Methods', 'DELETE');
res.header('Access-Control-Allow-Credentials', true);
next();
});
app.use('/app', express.static(path.join(__dirname, './app')));
app.get('/auth', (req, res) => {
res.json(UberAuth.login(req.query.code));
});
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, './index.html'));
});
app.listen(PORT,() => {
console.log(`server started on port ${PORT}`);
});
問題はapp.get( '/ auth' ....)部分にあります。私は「ログイン」関数を呼び出すようにしようとすると、何らかの理由<のために私が定義されて:
export const login = (authCode) => {
console.log(authCode);
return $.ajax({
url: "https://login.uber.com/v2/token",
method: "POST",
dataType: 'jsonp',
data: {
client_id: UBER_CLIENT_ID,
client_secret: UBER_CLIENT_SECRET,
grant_type: 'authorization_code',
redirect_uri: REDIRECT_URI,
code: authCode,
scope: 'profile'
}
});
};
他のどこでも私のプログラムでは、jQueryのは、正常に動作しますので、私はこのエラーを取得していますなぜ私は本当に理解していません。私はたくさんのことを試してみて、それを理解することはできません。私は表現するのが新しい、私は助けに感謝したい!
プロジェクトのどこにでもインポートされたように、ファイルの先頭にインポートされます。 –
'console.log($。ajax)'のときに表示されるものは? –