0
trevor.wilson created
I have added a second API to my environment
apis: {
default: {
url: 'https://localhost:44360',
rootNamespace: 'default.namespace',
},
myapi: {
url: 'http://myapi:1234',
rootNamespace: 'MyProj.myapi',
},
},
I would like to generate a proxy the API named myapi. I tried to generate the proxy using the following command:
abp generate-proxy -m myapi -t ng --api-name myapi
The abp cli successfully generated the proxy using this command. I then import the proxy service in my component:
import { MyService } from '@proxy/myproj/root/myservice.service';
but when I make calls to MyService the request has the default base URL. For example, calling myService.getList results in a request that looks like this:
https://localhost:44360/api/myapi/myservice
Why is the base url not being taken from myapi? What am I doing wrong?
1 Answer(s)
-
0
Hello,
What is the apiName of generated MyService class? It should be equal to the key in the
environment.ts
Example
import { Injectable } from '@angular/core'; @Injectable({ providedIn: 'root', }) export class MyService { apiName = 'MyApi'; }
apis: { default: { url: 'https://localhost:44360', rootNamespace: 'default.namespace', }, MyApi: { url: 'http://myapi:1234', rootNamespace: 'MyProj.myapi', }, },