I am trying to use ionic 4 google plus plugin to log in with google, but when I call :
googleLogin(){
this.nativeGoogleLogin();
}
async nativeGoogleLogin(): Promise<void> {
console.log('trying to log in with google');
const creds = {
'webClientId': '125618127989-slbv15359v8g76elj0664agipfedc5cn.apps.googleusercontent.com',
'offline': true,
'scopes': 'profile email'
}
try {
await this.googlePlus.login(creds).then(res => console.log(res)) // This line gets error
} catch(err) {
console.log(err)
}
}
I get error :
TypeError: Object(...) is not a function
at GooglePlus.login (index.js:27)
at BuyerLoginPage. (buyer-login.ts:109)
at step (buyer-login.module.ts:26)
at Object.next (buyer-login.module.ts:26)
at buyer-login.module.ts:26
at new t (polyfills.js:3)
at webpackJsonp.555.__awaiter (buyer-login.module.ts:26)
at BuyerLoginPage.webpackJsonp.555.BuyerLoginPage.nativeGoogleLogin
(buyer-login.ts:101)
at BuyerLoginPage.webpackJsonp.555.BuyerLoginPage.googleLogin (buyer-login.ts:117)
at Object.eval [as handleEvent] (BuyerLoginPage.html:141)
I mean, it isn't even firing cordova plugin, it's just error which says nothing to me. Anyone help ?
Related
Following along with the AWS-SDK examples/documentation in a Gatsby app, I have the workflow below setup to upload a file to my S3 bucket from the client directly however, the const data = await client.send(...) is returning Error TypeError: Cannot read properties of undefined (reading 'send') even though client definitely exists.
AWS is a new frontier, forgive me if my mistake is painfully obvious.
full error:
Error TypeError: Cannot read properties of undefined (reading 'send')
at eval (fromCognitoIdentityPool.js:26:1)
at step (tslib.es6.js:102:1)
at Object.eval [as next] (tslib.es6.js:83:1)
at fulfilled (tslib.es6.js:73:1)
Client initializer and accompanying uploader AJAX:
import { PutObjectCommand, S3Client } from "#aws-sdk/client-s3";
import { fromCognitoIdentityPool } from "#aws-sdk/credential-provider-cognito-identity";
const client = new S3Client({
region: process.env.GATSBY_AWS_S3_REGION,
credentials: fromCognitoIdentityPool({
clientConfig: { region: process.env.GATSBY_AWS_S3_REGION },
identityPoolId: process.env.GATSBY_AWS_USER_POOL_ID,
})
})
// Upload file to specified bucket.
export const run = async ({ email, photo }) => {
const uploadParams = {
Bucket: process.env.GATSBY_AWS_BUCKET_NAME,
Key: email + photo.name,
Body: photo,
};
try {
const data = await client.send(new PutObjectCommand(uploadParams));
console.log("Success", data);
return data;
} catch (err) {
console.log("Error", err);
}
};
The mistake was in the import:
import { fromCognitoIdentityPool } from "#aws-sdk/credential-provider-cognito-identity";
when it should have been:
import { fromCognitoIdentityPool } from "#aws-sdk/credential-providers";
I'm coding a discord bot and I've coded a function that fetches messages from a channel on discord, but the bot can't read messages. I couldn't solve the problem, can anyone help me?
Error Stack:
An error occurred while trying to fetch the channels: TypeError: Cannot read properties of undefined (reading 'messages')
at file:///C:/Users/Administrator/Desktop/gb-ac-bot/src/utils.js:7:88
at Array.map (<anonymous>)
at Object.allMessagesFromChannelList (file:///C:/Users/Administrator/Desktop/gb-ac-bot/src/utils.js:7:53)
at Object.updateServerInfo (file:///C:/Users/Administrator/Desktop/gb-ac-bot/src/scheduler.js:6:34)
at Timeout._onTimeout (file:///C:/Users/Administrator/Desktop/gb-ac-bot/src/index.js:53:21)
at listOnTimeout (node:internal/timers:559:17)
at processTimers (node:internal/timers:502:7)
My utils.js File:
const allMessagesFromChannelList = async (client) => {
const channels = global.channels.map(id => client.channels.cache.get(id))
try {
const messages = await Promise.all(channels.map(async channel => await channel.messages.fetch({ limit: 50 })))
return messages.map(collection => collection.map(value => value))
.flat()
.filter(msg => msg.author.id === global.botId)
} catch (error) {
console.error('An error occurred while trying to fetch the channels: ', error)
return []
}
}
The line of code that throws that error (line 7):
const messages = await Promise.all(channels.map(async channel => await channel.messages.fetch({ limit: 50 })))
I am trying to build my own staking page for my NFT project. I cloned a repo named gem-farm from github. But I am facing with an issue when I start it at localhost.
index.js?9d03:45 TypeError: Cannot read properties of undefined (reading 'protocol')
at isURLSameOrigin (isURLSameOrigin.js?3934:57:1)
at dispatchXhrRequest (xhr.js?b50d:145:1)
at new Promise (<anonymous>)
at xhrAdapter (xhr.js?b50d:15:1)
at dispatchRequest (dispatchRequest.js?5270:58:1)
at Axios.request (Axios.js?0a06:108:1)
at Axios.<computed> [as get] (Axios.js?0a06:129:1)
at Function.wrap [as get] (bind.js?1d2b:9:1)
at _callee$ (cluster.ts?b691:26:1)
at c (blocto-sdk.umd.js?758a:3:1)
I think it is caused by this file since it is the only file using axios
Where it imports axios:
import { TOKEN_PROGRAM_ID } from '#solana/spl-token';
import axios from 'axios';
import { programs } from '#metaplex/js';
This is where it uses axios:
async function getNFTMetadata(
mint: string,
conn: Connection,
pubkey?: string
): Promise<INFT | undefined> {
// console.log('Pulling metadata for:', mint);
try {
const metadataPDA = await Metadata.getPDA(mint);
const onchainMetadata = (await Metadata.load(conn, metadataPDA)).data;
const externalMetadata = (await axios.get(onchainMetadata.data.uri)).data;
return {
pubkey: pubkey ? new PublicKey(pubkey) : undefined,
mint: new PublicKey(mint),
onchainMetadata,
externalMetadata,
};
} catch (e) {
console.log(`failed to pull metadata for token ${mint}`);
}
}
I tried it on both PC & Macos. I couldn't find any solution. Thanks.
I am currently developing an app for educational purposes and facing a problem that is probably trivial but can't get around and solve it.
So basically I am trying to fetch some data from an external API (using Axios for that). I have divided my code into modules that I am exporting to index.js file and from that, I am instancing new Object and calling my async method getResults() which in return should give me data from API. From that point a get error
TypeError: Object(...) is not a function.
Here is an example code:
Module Search.js:
export default class Search {
constructor(query, num) {
this.query = query;
this.num = num;
}
async getResults() {
const url = 'API_URL';
const key = 'API_KEY';
try {
const res = await axios(`${url}?query=${this.query}&number=${this.num}&apiKey=${key}`);
this.result = res.data.results;
console.log(this.result);
} catch (error) {
console.log(error);
}
}
}
And here is index.js file:
import Search from "./models/Search";
const s = new Search('cheese', 2);
s.getResults()
And finally error in console:
TypeError: Object(...) is not a function
at Search._callee$ (Search.js:42)
at tryCatch (runtime.js:65)
at Generator.invoke [as _invoke] (runtime.js:303)
at Generator.prototype.<computed> [as next] (runtime.js:117)
at asyncGeneratorStep (Search.js:5)
at _next (Search.js:7)
at eval (Search.js:7)
at new Promise (<anonymous>)
at Search.eval (Search.js:7)
at Search.getResults (Search.js:65)
I am probably doing something wrong here, any help and insight would be appreciated. Thanks.
await axios(`${url}?query=${this.query}&number=${this.num}&apiKey=${key}`);
This is the line creating error,
axios is an object which you are trying to use as function
You probably wish to use get/post method provided by axios to call your endpoint
await axios.get(`${url}?query=${this.query}&number=${this.num}&apiKey=${key}`);
You can have a look how you want to use axios https://github.com/axios/axios
I am trying to run a lambda to set log retention of log groups in AWS to 14 days, I pulled up the following .js code from the web but when I am running it I am getting an error "errorMessage": "Cannot read property 'requestParameters' of undefined",. Runtime of Nodejs is 8.10.
Here is the .js I am running:
const AWS = require('aws-sdk');
const cloudwatchLogs = new AWS.CloudWatchLogs();
function setRetentionOfCloudwatchLogGroup(logGroupName, duration) {
let params = {
logGroupName : logGroupName,
retentionInDays: duration
};
return cloudwatchLogs.putRetentionPolicy(params).promise();
}
exports.handler = async (event) => {
const logGroupName = event.logGroupName ? event.logGroupName : event.detail.requestparameters.logGroupName;
try {
await setRetentionOfCloudwatchLogGroup(logGroupName, 14);
console.log('Retention has been set to ' + logGroupName + 'for 2 weeks');
return;
} catch(error) {
console.error(error);
throw error;
}
};
Here is the error I am getting:
Response:
{
"errorType": "TypeError",
"errorMessage": "Cannot read property 'requestParameters' of undefined",
"trace": [
"TypeError: Cannot read property 'requestParameters' of undefined",
" at Runtime.exports.handler (/var/task/index.js:14:81)",
" at Runtime.handleOnce (/var/runtime/Runtime.js:63:25)",
" at process._tickCallback (internal/process/next_tick.js:68:7)"
]
}
The event’s detail property on line 14 is not being set. Not sure if you expect the event to have that in every call, but I imagine that there are cases when no details need to be passed through the event handler and the property is left empty. A simple null check will fix this.