Sending arrays as query parameters to express does not work - express

I think that one should be able to send a url like this to express:
/?some_arr[]=1&some_arr[]=2
and get in req.query: {some_arr: ['1','2']}
but I tried it and I get: {some_arr: '2'}
Is this how it is supposed to be? What can be wrong? Is there any config settings to enable the array feature?
This is in an existing, large project. Could this have been turned off in some way?

I found out that the project since earlier had the line app.use(hpp()); which apparently is a package to explicitly remove the array feature...

do something like that-
/?some_arr=1&some_arr=2
and now on your express code-
app.get('/', function(req, res, next) {
console.log(req.query) //
res.send(200)
}

Related

Redis: Cannot perform full-text search operations

I got error saying "ReplyError: Car:index: no such index". I am indexing by "description". As you can see on the terminal part contains all the needed info and I am not sure what is causing the problem. Help is welcome.
I've been trying to follow Fireship tutorial on Redis, copied his code https://fireship.io/lessons/redis-nextjs/
In Redis-om version 0.3.6, you can add following code in your API:
export async function createIndex() {
await connect();
const repository = client.fetchRepository(schema);
await repository.createIndex();
}
And Also ensure you only create index once ONLY.
It will work after you created an index.
As Guy Royse mentioned in the comments - The problem is solved by calling createIndex API.

How to make insult command(discord.py)

i'm making an insult command,its making a JSONDecode Error
any solution...
#client.command(pass_context=True)
async def insult(ctx):
async with aiohttp.ClientSession() as session:
request = await session.get('https://evilinsult.com/generate_insult.php?lang=en&type=json')
insultjson = await request.json(content_type='text/html')
await ctx.send(url=insultjson['insult'])
The problem is most probably the link. Instead of &, just use &.
Plus, they seem to have a plain text option too - replace type=json with type=text in the same link and you should be able to use it without having to deal with JSON at all. Check out evilinsult.com's GitHub repo
Also, please always paste your exact errors - it helps us give you a better answer.

What is the equivalent for Auth.updateUserAttributes in amplify_auth_cognito

Link 1.
What is the equivalent for
const user = await Auth.currentAuthenticatedUser();
const result = await Auth.updateUserAttributes(user, {
'custom:favorite_flavor': 'Strawberry'
});
in Flutter
amplify_core: '<1.0.0'
amplify_auth_cognito: '<1.0.0'
Took a look and found the simple answer that the exact copy over does not exists as i'm sure you have realized at this point.
The link:
https://docs.amplify.aws/lib/auth/manageusers/q/platform/js/ will fail to give you any comparable Flutter etc... pages & if you try it will return "Flutter is not supported on this page. Please select one of the following: Javascript."
Unfortunately, Javascript is not supported in android/IOS though there was some stuff out there to partially work with it https://medium.com/flutter-community/using-javascript-code-in-flutter-web-903de54a2000.
Hopefully this answer will become obsolete over time as more work is put into the needed functionality.

Recommended dynamic runtime configuration technique on nuxtjs (other than dotenv)

I have been trying to use publicRuntimeConfig / privateRuntimeConfig
On nuxt 2.4.1, I have defined my runtime config as follows on nuxt.config.js
publicRuntimeConfig: {
DATA_API_HOST_URL: process.env.VUE_APP_DATA_API_HOST_URL,
},
privateRuntimeConfig: {
AUTH_APP_CLIENT_SECRET: process.env.VUE_APP_AUTH_APP_CLIENT_SECRET,
},
and calling it as follows on my login.vue
asyncData( ctx ) {
console.log(ctx.$config.DATA_API_HOST_URL)
//some activity
}
The keys are showing up on $config inside asyncData. I debugged on chrome dev tools. But value is not read from process.env.VUE_APP_DATA_API_HOST_URL. The value is showing up as undefined. However, process.env.VUE_APP_DATA_API_HOST_URL is showing the value OK. The whole point is to move away from process.env.
this.$config.DATA_API_HOST_URL also does not access the values.
'${DATA_API_HOST_URL}' is shown in examples but I believe it is only for explicit param declarations at asyncData like asyncData( { $config : {DATA_API_HOST_URL}).
When I pass values as it is using DATA_API_HOST_URL: process.env.VUE_APP_DATA_API_HOST_URL || 'https://test.api.com', it seems to copy the value fine using ctx.$config.DATA_API_HOST_URL!
Looking to me like copying process.env to *RuntimeConfig has a problem!
What is the recommended way of importing and using runtime configurations?
As per documentation in the Nuxt blog post you marked, the feature your are trying to use is released in 2.13 (you´re using 2.4 if i not misunderstood). That could be the reason behind the behaviour you're seeing.
I'd recommend update your project dependencies or trying another approach.
I think you should use Docker to set dynamic runtime config like link below:
https://dev.to/frontendfoxes/dockerise-your-nuxt-ssr-app-like-a-boss-a-true-vue-vixens-story-4mm6

express define routes confusion app.use()

app.use('/api/users',require('./routes/api/users'));
app.use('/api/auth',require('./routes/api/auth'));
app.use('/api/profile',require('./routes/api/profile'));
app.use('/api/posts',require('./routes/api/posts'))
When i change the routes from 'api' to any other words the server keep giving me 404 not found error and I also changed axio method to the corresponding words.
for example app.use('/ddd/posts',require('./routes/api/posts')) and corresponding axios: const res = await axios.get('/ddd/posts');
please help
If this:
app.use('/api/posts',require('./routes/api/posts'))
works with:
axios.get('/api/posts');
Then, this:
app.use('/ddd/posts',require('./routes/api/posts'))
will work just fine with:
axios.get('/ddd/posts');
Unless there is something interfering with your modified server. Things that could be interfering:
A proxy configured only to allow certain paths through
Your new server didn't get started properly, perhaps because the prior generation of the server is still running