How can I extract querystring parameters email
, job
, and source
from the following URL?
I want to use these parameters in my service class:
@Injectable()
export class TesteService{
constructor(){}
async fetchDataFromUrl(urlSite: URL){
const url = new URLSearchParams(urlSite.search)
const emailParam = url.get("email");
console.log(emailParam);
}
}
And in the controller:
@UseGuards(AuthGuard())
@Controller('Test')
export class test{
constructor(private readonly testeService: TesteService){}
@Get('loginTest')
@UsePipes(ValidationPipe)
async redirect(){
return await this.testeService.fetchDataFromUrl(url);
}
}
I tried manually inputting the URL, but VS Code comments out the code. Once I retrieve the parameters from the URL, I need to redirect to another URL. How can I achieve this?
Any advice on accessing querystring parameter values?