[英]Angular 7 8 9 after ng build --prod API is not working
Angular 7 8 9 after ng build API is proper working but, after --prod build its not working, i checkd before post API url is proper pass, but not hit... Angular 7 8 9 after ng build API is proper working but, after --prod build its not working, i checkd before post API url is proper pass, but not hit...
service file:服务文件:
register(userData: RegisterUser): Observable<RegisterUserResponse>{
return this.http.post<RegisterUserResponse>(this.apiRoutes.signup, userData);
}
environment file:环境文件:
const serverUrl = 'http://roo2.in';
export const environment = {
serverUrl: `${serverUrl}`,
apiUrl: `${serverUrl}/api`,
production: true
}
Based on your comment if url is passed correctly and not hit on, it could be that you didn't subscribe to your observable根据您的评论,如果 url 被正确传递并且没有被点击,可能是您没有订阅您的 observable
register(userData: RegisterUser): Observable<RegisterUserResponse>{
return this.http.post<RegisterUserResponse>(this.apiRoutes.signup, userData);
}
somewhere else you needed to你需要的其他地方
this.xxxService.register(someData).subscribe(result => console.log(result))
HTTP_INTERCEPTORS issue. HTTP_INTERCEPTORS 问题。 after remove INTERCEPTORS it's working properly on --prod build
删除 INTERCEPTORS 后,它在 --prod build 上正常工作
providers: [
// {
// provide: HTTP_INTERCEPTORS,
// useClass: InterceptorService,
// multi: true
// }]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.