我试图使用unsplash api制作图像搜索应用。我可以通过像这样的浏览器编写的URL访问API 这个,但我无法将代码中得到它的工作。有人可以帮忙吗?另外也没有错误发生,我正在尝试将json文件打印到控制台。我在这里关注此文档。
import React, { Component } from 'react';
import './App.css';
class App extends Component {
constructor(props) {
super(props);
this.state = {
applicationId: '1424074b20f17701ec8c0601fd15ca686c70e2cb0e645f8137533d8063e664bc',
url: 'https://api.unsplash.com/search/photos?client_id=',
pagecount: 1
}
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
let query = document.getElementById('input').value;
fetch(this.state.url + this.state.applicationId + '&query=' + query + '&page=' + this.state.pagecount)
.then(json => {
console.log(json)
})
.catch(err => console.log('error occured' + err));
}
render() {
return (
<div className="App">
<form id='form'>
<input type='text' id='input' ></input>
<input type='submit' …Run Code Online (Sandbox Code Playgroud) 所以我正在学习 Elixir 和 Pheonix 看起来太多而无法开始学习,所以我使用 Plug and Poison 制作了一个简单的 JSON Rest API,但要查看任何更改,我需要停止服务器并mix run --no-halt再次运行。我来自nodeJS,它只nodemon跟踪依赖于根模块的所有文件,并在看到任何更改时重新加载整个服务器。有没有类似的 mix 或 Elixir 的东西?我知道您可以使用 OTP 重新加载代码的特定部分,如果我的服务器在保存时执行此操作,那就最好了,但现在我只想更快地响应我所做的事情。有人能指出我正确的方向吗?
例如,我有一个对象和数组本身:
const object =
{
a: {
b: [
0: 'something',
1: {
c: 'the thing that I need',
},
],
},
};
Run Code Online (Sandbox Code Playgroud)
以及具有键值的数组:
const array =
[
'a', 'b', '1', 'c',
];
Run Code Online (Sandbox Code Playgroud)
如何使用此数组在对象中导航并为我提供值?也许有办法做到这一点ramda?或者只是为了让它看起来像人类可读.