Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/11.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
Wordpress WP rest API未正确响应_Wordpress_Restapi_Get Request - Fatal编程技术网

Wordpress WP rest API未正确响应

Wordpress WP rest API未正确响应,wordpress,restapi,get-request,Wordpress,Restapi,Get Request,我使用了两个get请求,分别使用$.when$和wp。但是在使用concat方法组合这些请求之后,我很难在前端从组合的请求中呈现数据 这是我的要求: getResults() { $.when( $.getJSON(`${universityData.root_url}/wp-json/wp/v2/posts?search=${this.searchField.val()}`), $.getJSON(`${universityDat

我使用了两个get请求,分别使用$.when$和wp。但是在使用concat方法组合这些请求之后,我很难在前端从组合的请求中呈现数据

这是我的要求:

getResults() {
        $.when(
            $.getJSON(`${universityData.root_url}/wp-json/wp/v2/posts?search=${this.searchField.val()}`),
            $.getJSON(`${universityData.root_url}/wp-json/wp/v2/pages?search=${this.searchField.val()}`).then((posts,pages) => {
                    console.log(posts);
                    let combinedResults = posts.concat(pages);
                    console.log(combinedResults);
                    // console.log(combinedResults.map( data => {
                    //  console.log (data.title.rendered);   
                    // }));
                this.resultsDiv.html(`
                <h2 class="search-overlay__section-title">General Information</h2>
                ${combinedResults.length ? '<ul class="link-list min-list">' : '<p>No match results found</p>'}
                  ${combinedResults.map(data => `<li><a href="${data.link}">${data.title.rendered}</a></li>`).join('')}
                ${combinedResults.length ? '</ul>' : ''}
              `);
                this.isSpinnerVisible = false;
            })
            );
  }
getResults(){
美元。什么时候(
$.getJSON(`${universityData.root_url}/wp json/wp/v2/posts?search=${this.searchField.val()}`),
$.getJSON(`${universityData.root_url}/wp json/wp/v2/pages?search=${this.searchField.val()}`)。然后((帖子,页面)=>{
控制台日志(posts);
让combinedResults=posts.concat(页数);
console.log(组合结果);
//console.log(combinedResults.map)(数据=>{
//console.log(data.title.rendered);
// }));
this.resultsDiv.html(`
一般资料
${combinedResults.length?'':''}
`);
this.isspinervible=false;
})
);
}
注意:我的控制台记录了数据,它似乎工作正常,但唯一的问题发生在我尝试将数据带到前端时

下面是错误: