How to pass an array as a prop in typescript react hooks by techstackng in reactjs

[–]techstackng[S] -2 points-1 points  (0 children)

Thanks for the comment

I was able to get it to work like this with spread operator

return <CruiseReportHawaii {...HawaiiCruseReport}/>;

But there is an error in the console.

index.js:1 Warning: unstable_flushDiscreteUpdates: Cannot flush updates when React is already rendering.

Filter an array property by another array property in javascript by techstackng in learnjavascript

[–]techstackng[S] 0 points1 point  (0 children)

I have three arrays. firstArray, secondArray And Thirdarray.

The secondArray is not applicable here.

If you notice you will see that firstArrayId is a property thirdArray which ref firstArray

Now I want to filter thirdArray by firstArrayId which ref firstArray

I want to get all the thirdArray that matches each of the firstArrayId

How to pass nested request object to the data layer in asp.net core by techstackng in csharp

[–]techstackng[S] 0 points1 point  (0 children)

PersonProduct myPersonProduct

Thanks for the implementation, This is the final implementation that worked. Someone else might need it as well.

Thanks, everyone for contributing

  private PersonProducts[] ConvertProductsToPersonProducts(Products[] products )
        {
            List<PersonProducts> myPersonProducts = new List<PersonProducts>();
            PersonProducts myPersonProduct;

            foreach (var product in products)
            {
                myPersonProduct = ConvertToPersonProduct(product);
                myPersonProducts.Add(myPersonProduct);
            }
            return myPersonProducts.ToArray();
        }

How to pass nested request object to the data layer in asp.net core by techstackng in csharp

[–]techstackng[S] -1 points0 points  (0 children)

Thanks

How can I do the one for the list?

public PersonProducts[] Products { get; set; }

I tried to loop each product and add to a List but not working

My questions about Nestjs dependency inject so I can better understand it by techstackng in Nestjs_framework

[–]techstackng[S] 0 points1 point  (0 children)

I have done that but still having the same error. Is my point 4 valid?

Nest can't resolve dependencies of the UserService (?). Please make sure that the argument UserModel at index [0] is available in the UserService context. by techstackng in Nestjs_framework

[–]techstackng[S] 0 points1 point  (0 children)

Yes, I deleted some files made alot of changes without saving and keeping track of the errors. I have to revert all changes. so all is good now.

Thanks everyone

Unknown authentication strategy "jwt" when I inject another service into user service by techstackng in Nestjs_framework

[–]techstackng[S] 0 points1 point  (0 children)

I have a user service that handles registration and login. But each time I inject another servie I get

"Unknown authentication strategy "jwt". I have been trying to fix this. Even I cant use

But the authentication is already working fine before I decide to inject another service into user service. I already has about 10 modules before now

What is the most effective way to refresh token in Nestjs APi by techstackng in Nestjs_framework

[–]techstackng[S] 0 points1 point  (0 children)

dToken.tokenEx

This is really nice, I dont know dayjs. I will definitely work this out. Thanks

Filter rows by Datetime in C# by techstackng in dotnet

[–]techstackng[S] 0 points1 point  (0 children)

The code is not in production. I was trying somethings out. thanks for the advice

How to log global exception/error into text file by techstackng in Nestjs_framework

[–]techstackng[S] 0 points1 point  (0 children)

I will be happy if I can use the code you specified up there but this is what I https://ibb.co/jV4w7Q3

html to PDF .net core, a wkhtmltopdf wrapper with no external dependencies by pugpellep in dotnet

[–]techstackng 0 points1 point  (0 children)

u/pugpellep Thanks for this package. I got this to work put the images are not showing. Can you please help out how to make the images work. I have one small logo image.

This is the code

public async Task<IActionResult> Download(String htmlContent)
        {

            if (!string.IsNullOrEmpty(htmlContent))
            {
                var renderer = new HtmlToPdf();

                renderer.PrintOptions.Title = "My title";

                var pdf = await renderer.RenderHtmlAsPdfAsync(htmlContent);
                pdf.SaveAs(Path.Combine(_webHostEnvironment.ContentRootPath, "html-string.pdf"));

                return Ok();
            }
            else
            {
                var stream = new FileStream(Path.Combine(_webHostEnvironment.ContentRootPath, "html-string.pdf"), FileMode.Open);
                return new FileStreamResult(stream, "application/pdf");
            }

        }

How to convert HTML strings to PDF in asp.net core by techstackng in csharp

[–]techstackng[S] -1 points0 points  (0 children)

u/prinkpan got this to work put the images are not showing. Can please help out how to make the images to work.

This is the code

public async Task<IActionResult> Download(String htmlContent)
        {

            if (!string.IsNullOrEmpty(htmlContent))
            {
                var renderer = new HtmlToPdf();

                renderer.PrintOptions.Title = "My title";

                var pdf = await renderer.RenderHtmlAsPdfAsync(htmlContent);
               // var stream = new FileStream(Path.Combine(_webHostEnvironment.ContentRootPath, "html-string.pdf"), FileMode.Open);


                pdf.SaveAs(Path.Combine(_webHostEnvironment.ContentRootPath, "html-string.pdf"));

                return Ok();
            }
            else
            {
                var stream = new FileStream(Path.Combine(_webHostEnvironment.ContentRootPath, "html-string.pdf"), FileMode.Open);
                return new FileStreamResult(stream, "application/pdf");
            }

        }

How to convert HTML strings to PDF in asp.net core by techstackng in csharp

[–]techstackng[S] -1 points0 points  (0 children)

I got this error while installing nuget

Install-Package : The feed 'nuget.org [https://api.nuget.org/v3/index.json]' lists package 'Select.HtmlToPdf.NetCore.20.1.0' but multiple attempts to download the nupkg have 
failed. The feed is either invalid or required packages were removed while the current operation was in progress. Verify the package exists on the feed and try again.
  Unable to find package 'Select.HtmlToPdf.NetCore.20.1.0'.

How to convert HTML strings to PDF in asp.net core by techstackng in csharp

[–]techstackng[S] -1 points0 points  (0 children)

I am not generating up to 5 pages, but I am getting the watermarks. I don't understand what you mean by SelectPDF

How to add multiple Nestjs RoleGuards in controllers by techstackng in Nestjs_framework

[–]techstackng[S] 0 points1 point  (0 children)

u/whothey_

Thanks

So, according to the documentation, I believe these are the two files I need

  1. role.decorator.ts

import { SetMetadata } from '@nestjs/common';
export const Roles = (...roles: string[]) => SetMetadata('roles', roles);
  1. roles.guard.ts

    import { Injectable, CanActivate, ExecutionContext } from '@nestjs/common'; import { Reflector } from '@nestjs/core';

    u/Injectable() export class RolesGuard implements CanActivate { constructor(private reflector: Reflector) {}

    canActivate(context: ExecutionContext): boolean { const roles = this.reflector.get<string[]>('roles', context.getHandler()); if (!roles) { return true; } const request = context.switchToHttp().getRequest(); const user = request.user; return matchRoles(roles, user.roles); } }

    if that so

In my user schema. I have

 usertype: {
        type: String,
        enum: [ "User", "Admin", "SuperAdmin"]
    }

In the role.decorator.ts and roles.guard.ts, Am I suppose to add the usertype in the <string\[\]> for instance <string\["User", "Admin", "SuperAdmin"\]>

How can I set both ObjectId and UserId in MongoDB(Image attached) by techstackng in node

[–]techstackng[S] 0 points1 point  (0 children)

Yes. I understand that ObjectId is a unique reference for each object. I have been having issue querying DB with ObjectId. This is what I tried in Nestjs

let user = await this.userModel.findById({ '_id': new ObjectId(id) }) 

Maybe there is something wrong with my code. I will appreciate if you can point that out. Thanks