0

2020欧洲杯手机版注册I am trying to get data from a 3rd-party API, but cannot get any data back from it in my program. However, I can get it to work via Postman.

params in Postman:

JSON from Postman:

JSON from console:

2020欧洲杯手机版注册the code in question:

const consola = require('consola');const express = require('express');const axios = require('axios');const app = express();// GET - /api/titleapp.get('/', (req, res) => {  const title = 'and then there were none'; // this is just until data is coming from user input  const replaceSpaces = (str) => str.split(' ').join('+');  axios    .get('http://tastedive.com/api/similar', {      params: {        q: replaceSpaces(title),        type: 'books',        info: 1,        limit: 7,        k: process.env.TASTE_DIVE_KEY,      },    })    .then(({ data }) => {      consola.ready({        message: `data from axios server ${JSON.stringify(data)}`,        badge: true,      });      res.json(data);    })    .catch((error) => {      res.status(400).json(error);      consola.error({        message: `error from axios server ${error}`,        badge: true,      });    });});

Does anybody know what could be causing this discrepancy? I have the same params in both my code and in Postman, but I'm not getting the full data back in my app that I am in Postman.

  • Check this out: e-335thgr.com/a/53667487/5764220 If it doesn't help you, let me know and I'll look into it. – Sivcan Singh 2 days ago
  • How about replaceSpaces method? Maybe you it is not returning correct data? Or process.env.TASTE_DIVE_KEY maybe is wrong? Try to console.log them two. – robmax yesterday
  • Sivcan- I'll give it a try. Looks interesting. On my phone at this point, so I'll have to get back to you about it tomorrow. – Jim Strother yesterday
  • robmax- I did double check both of those and they are returning what I'm expecting. – Jim Strother yesterday
  • Sivcan- the code generation feature in postman didn't give me anything that I didn't already have in my code. – Jim Strother 3 hours ago

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy2020欧洲杯手机版注册

Browse other questions tagged or ask your own question.