InternalError - Библиотека Axios - React native - PullRequest
0 голосов
/ 21 января 2019

Я установил библиотеку axios как:

npm install axios --save

Это дает следующие выходные данные:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ axios@0.18.0
updated 1 package and audited 34211 packages in 5.933s
found 0 vulnerabilities

После этого я добавил этот код для API:

import {Text , View} from 'react-native';
import React, { Component } from 'react';
import axios from 'axios';


class AlbumList extends Component {
componentWillMount() {
  axios.get('http://rallycoding.herokuapp.com/api/music_albums')
   .then(response => console.log(response));

}

render() {
    return (
        <View>
        <Text> Album List </Text>
        </View>
    );
  }
}

export default AlbumList;

Но получить этот вывод: (с помощью команды react-native run-android)

Body: {"type": "InternalError", "errors": [], "message": "Metro Bundler обнаружилвнутренняя ошибка, проверьте вывод ошибок терминала для получения более подробной информации "}

=============== РЕДАКТИРОВАТЬ ==================

    npm start

> albums@0.0.1 start /home/abc/albums
> node node_modules/react-native/local-cli/cli.js start

┌──────────────────────────────────────────────────────────────────────────────┐
│                                                                              │
│  Running Metro Bundler on port 8081.                                         │
│                                                                              │
│  Keep Metro running while developing on any JS projects. Feel free to        │
│  close this tab and run your own Metro instance if you prefer.               │
│                                                                              │
│  https://github.com/facebook/react-native                                    │
│                                                                              │
└──────────────────────────────────────────────────────────────────────────────┘

events.js:173
      throw er; // Unhandled 'error' event
      ^

Error: listen EADDRINUSE: address already in use :::8081
    at Server.setupListenHandle [as _listen2] (net.js:1254:14)
    at listenInCluster (net.js:1302:12)
    at Server.listen (net.js:1390:7)
    at /home/abc/albums/node_modules/metro/src/index.js:193:18
    at new Promise (<anonymous>)
    at Object.<anonymous> (/home/abc/albums/node_modules/metro/src/index.js:192:12)
    at Generator.next (<anonymous>)
    at step (/home/abc/albums/node_modules/metro/src/index.js:50:30)
    at /home/abc/albums/node_modules/metro/src/index.js:61:15
Emitted 'error' event at:
    at Server.WebSocketServer._onServerError (/home/abc/albums/node_modules/ws/lib/WebSocketServer.js:82:50)
    at Server.emit (events.js:193:15)
    at emitErrorNT (net.js:1281:8)
    at processTicksAndRejections (internal/process/next_tick.js:76:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! albums@0.0.1 start: `node node_modules/react-native/local-cli/cli.js start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the albums@0.0.1 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/abc/.npm/_logs/2019-01-21T12_56_22_397Z-debug.log

Любые предложения будут оценены!Спасибо!

...