Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angular 离子-API状态404_Angular_Api_Url_Ionic Framework - Fatal编程技术网

Angular 离子-API状态404

Angular 离子-API状态404,angular,api,url,ionic-framework,Angular,Api,Url,Ionic Framework,我目前正在学习爱奥尼亚框架,我在Youtube上找到了一个教程,它正在用数据创建新闻应用程序。我一步一步地遵循教程,在我的浏览器中检查了一段时间后,它显示了以下错误: 得到http://localhost:8100/$%7BAPI_URL%7D/$%7BAURL%7D&apiKey=$%7BAPI_KEY%7D 404 还有这个 core.js:9110错误HttpErrorResponse{headers:HttpHeaders,状态:404,状态文本:未找到,url:http://local

我目前正在学习爱奥尼亚框架,我在Youtube上找到了一个教程,它正在用数据创建新闻应用程序。我一步一步地遵循教程,在我的浏览器中检查了一段时间后,它显示了以下错误:

得到http://localhost:8100/$%7BAPI_URL%7D/$%7BAURL%7D&apiKey=$%7BAPI_KEY%7D 404

还有这个

core.js:9110错误HttpErrorResponse{headers:HttpHeaders,状态:404,状态文本:未找到,url:http://localhost:8100/$%7BAPI_URL%7D/$%7BAURL%7D&apiKey=$%7BAPI_KEY%7D,确定:false,}

所以这个网址:http://localhost:8100/$%7BAPI_URL%7D/$%7BAURL%7D&apiKey=$%7BAPI_键%7D未找到

这是我的密码。My environment.ts:

这是我的新闻。服务。ts:

在这个news.service.ts中,当我将鼠标悬停在url上时,它向我显示此消息“url”已声明,但其值从未读取。ts6133和此参数“url”隐式具有“any”类型,但可以从用法推断出更好的类型。ts7044。对于const API_url和const API_,键是相同的错误:已声明,但其值从未读取。ts6133。也许这就是问题所在

这是我的新闻

和我的app.module.ts:


那个么,当一切都和教程中的一样时,为什么会显示这个错误呢?这个错误有什么解决办法吗?请帮忙!谢谢。

通常,错误代码404表示“未找到请求的URL”

出现此错误是因为您使用的是模板文字表达式

`${blabla}` 
使用单标记引用,这是错误的

'  '
您应该使用反勾号来获取所需的值

` `
因此,在您的代码中,将新闻服务表单更改为

news.service.ts:

为此:


玩得开心,

哎哟。。现在是凌晨两点,我很累,但我不能离开,我没有。先生,谢谢您的友好回答!
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { RouteReuseStrategy } from '@angular/router';

import { IonicModule, IonicRouteStrategy } from '@ionic/angular';
import { SplashScreen } from '@ionic-native/splash-screen/ngx';
import { StatusBar } from '@ionic-native/status-bar/ngx';

import { HttpClientModule } from '@angular/common/http';

import { AppRoutingModule } from './app-routing.module';
import { AppComponent } from './app.component';

@NgModule({
    declarations: [ AppComponent ],
    entryComponents: [],
    imports: [ BrowserModule, IonicModule.forRoot(), AppRoutingModule, HttpClientModule ],
    providers: [ StatusBar, SplashScreen, { provide: RouteReuseStrategy, useClass: IonicRouteStrategy } ],
    bootstrap: [ AppComponent ]
})
export class AppModule {}
`${blabla}` 
'  '
` `
getData(url) {
    return this.http.get('${API_URL}/${url}&apiKey=${API_KEY}');
}
 getData(url) {
    return this.http.get(`${API_URL}/${url}&apiKey=${API_KEY}`);
}