I have the following Javscript code:
const authenticationTypeMapping = (payload) => {
const { API_CONFIG } = process.env;
try {
const apiConfig = JSON.parse(API_CONFIG.toString('utf8'));
// set authenticationType to Federated for production
if (apiConfig.API_BASE_URL.includes('prd')) {
payload.authenticationTypeName = 'Federated';
// set authenticationType to Federated for dev or UAT
} else if (apiConfig.API_BASE_URL.includes('dev') || apiConfig.API_BASE_URL.includes('uat')) {
payload.authenticationTypeName = 'Basic';
}
} catch (err) {
console.log(`Failed to map authenticationType. Unable to parse Secret: ${err}`);
}
return payload;
};
But every time when call this method it return the following error: Failed to map authenticationType: TypeError: Cannot read properties of undefined (reading 'toString')
It is obviously related to this line in the code:
const apiConfig = JSON.parse(API_CONFIG.toString('utf8'));
How can fix that error?
Related
This is the error I am getting when I try to deploy the code:
Error: ERROR processing /home/anooj-patnaik/hh-fcc/hardhat-fund-me-fcc/deploy/00-deploy-mocks.js:
TypeError: Cannot read properties of undefined (reading 'length')
const { network } = require("hardhat")
const {
developmentChains,
DECIMALS,
INITIAL_ANSWER,
} = require("../helper-hardhat-config")
module.exports = async ({ getNamedAccounts, deployments }) => {
const { deploy, log } = deployments
const { deployer } = await getNamedAccounts()
if (developmentChains.includes(network.name)) {
log("Local Network Detected! Deploying Mocks...")
await deploy("MockV3Aggregator", {
contract: "MockV3Aggregator",
from: deployer,
log: true,
args: [DECIMALS, INITIAL_ANSWER],
})
log("Mocks deployed")
log("---------------------------")
}
}
module.exports.tags = ["all", "mocks"]
I have defined all the variables in a hardhat-helper-config.js and hardhat.config.js. The MockV3Aggregator is in a separate contract
Tried to deploy the code above and faced with an error
When you call await getNamedAccounts(), it looks in your hardhat.config.js for the namedAccounts section, and reads the length of the named accounts.
You'll want to make sure this is in there!
namedAccounts: {
deployer: {
default: 0, // here this will by default take the first account as deployer
},
},
Hello Im getting error: Cannot read properties of undefined (reading 'split').
When I see it in the console
If I click the link to the error it shows me the browser.umd.js file with this line:
any one knows whats the problem?
code:
const verifyJwt = (req,res,next) => {
console.log('entered middle');
let name = 'token=';
const header = req.headers['cookie'];
const token = header && header.split('=')[1];
if (!token) return res.status(401).send({msg: "Login first please!"})
jwt.verify(token, process.env.TOKEN_KEY, (err, user) => {
if(err) return res.status(403).send({msg:"Not authoraized"})
next();
});
}
module.exports = verifyJwt
The problem occurs because of an other error that was found in the code but havent notice, because of this the string was undefined value and does not have the func split.
I've been trying to fix this problem for 2-3 days but I'm unable to fix it. It occurs when I try building the Application with yarn build
here's the error
> Build error occurred
TypeError: Cannot read properties of null (reading 'toString')
my code-
export async function getStaticPaths(){
// get the user's image from another table
const users = await prisma.UserInfo.findMany();
const paths = users.map((user: any) => ({
params: { pid: user.name},
// Error: A required parameter (pid) was not provided as a string in getStaticPaths for /users/[pid].
}))
console.log(paths)
return { paths, fallback: false }
}
export async function getStaticProps({ params }: any) {
const user = await prisma.UserInfo.findUnique({
where: {
name: params.pid
},
});
console.log(user)
return { props: { user } };
}
any ideas on how to fix this?
thanks
Great day'
Hello, I had this problem like 1 week ago, and still can't solve it. So, I'm trying to do per-server prefixes, but when I boot up the bot, it sends the boot-up confirmation message, but then it says the error and it shuts down. Here is the error:
guildPrefixes[guildId] = result.prefix
^
TypeError: Cannot read property 'prefix' of null
I can't see anything wrong here, but anyways, here is the code:
module.exports.loadPrefixes = async (client) => {
await mongo().then(async (mongoose) => {
try {
for (const guild of client.guilds.cache) {
const guildId = guild[1].id
const guildPrefixes = {}
const result = await commandPrefixSchema.findOne({_id: guildId})
guildPrefixes[guildId] = result?.prefix || dprefix
console.log(result)
}
console.log('[INFO] Prefixes have been loaded')
} finally {
mongoose.connection.close()
}
})
}
This is a function for login
I am getting the 'cannot read property rol of undefined' error: here is my vueJs code:
methods: {
send: function() {
this.error = null;
this.showLoader = true;
this.$http
.post("/login", new FormData(document.getElementById("LoginUser")), {
reponseType: "json"
})
.then(response =>
{
localStorage.setItem("role", response.data.data.rol);
location.href = "/";
},
fail => {
this.showLoader = false;
this.password = "";
for (let message of fail.data.data.messages) {
this.error = this.$t(
message.message.toLowerCase().replace(/ /g, "_")
);
}
}
);
}
}
what am i doing wrong? Thanks
I have been trying to solve this for a long time but I have not succeeded
As per the documentation for vue-resource, the response object has no property data. What you're looking for is either response.body or response.json() to resolve response.body into a JSON object.