首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Contentful不启动请求

Contentful不启动请求
EN

Stack Overflow用户
提问于 2018-11-12 09:38:52
回答 1查看 340关注 0票数 0

我从满足感开始,我得到了这个错误。

代码语言:javascript
复制
Import error, can't find file:
./zlib_bindings

我没有做任何事情,我只是像docs中描述的那样启动了一个请求。

这是componentDidMount函数的代码。我查看了空间id和访问令牌在我的申请中

代码语言:javascript
复制
import React, { Component } from 'react';
import { render } from 'react-dom';
import contentful from 'contentful'

import './style.css';
import 'bulma/css/bulma.css'

import SearchComponent from './components/SearchComponent'
import ProductSection from './components/productSection'


class App extends Component {
  constructor() {
    super();
    this.state = {
      name: 'React'
    };
  }

  componentDidMount() {

    var client = contentful.createClient({
      space: 'space_ID_here',
      accessToken: 'access_here'
    })


    // This API call will request an entry with the specified ID from the space defined at the top, using a space-specific access token.
    client.getEntries()
      .then(function (entries) {
        // log the title for all the entries that have it
        entries.items.forEach(function (entry) {
          if (entry.fields.productName) {
            console.log(entry.fields.productName)
          }
        })
      })


  }
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2018-11-12 12:58:52

这很奇怪..。我检查了stackblitz链接,它还要求将http安装为不应该需要的依赖项。我几乎可以肯定,zlib_bindings与内容sdk无关,但是在Stackblitz或您正在运行的环境中正在发生其他事情。

您可以在react 这里中找到一个正在运行的示例。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/53259367

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档