Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
219 views
in Technique[技术] by (71.8m points)

Angular decode the request url

post<T>(url: string, body: any): Observable<T> { 
    return this.http.post<T>(this.baseUrl + decodeURIComponent(url), body);
}

add(data){
    return this.commonHttpService.post(`/organisations?/add`,data);
}

onSubmit() {
    const controls = this.addForm.controls;
    const data = {
        name: controls.value
    };
    this.homeService
    .add(data)
    .pipe(catchError(err => of(err)
    ), tap((resp: any) => {
    if (resp.status_code === 200) {
        Swal.fire('Ensemble added successfully!', '', 'success') }

Request URL I recieved- http://X.XXX.XXX.XXX/api/organisations%E2%80%8B/add

Expected Request URL- http://X.XXX.XXX.XXX/api/organisations/add

I added the decodeURIComponent to the url but still I am getting this request url. How can we solve this? Tried many ways.

question from:https://stackoverflow.com/questions/65517650/angular-decode-the-request-url

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

You must be out of luck. I copy/paste your code in the javascript console and it showed me an invisible character.

The code constains an invisible dot between organistations and "/add"

Try to rewrite your code by hand


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...