Skip to content
Advertisement

Tag: request

Unable to retrieve specific elements from JSON api

Implement a function fetchDataForUser, which fetches data from a remote JSON api and then returns a part of it. Since this is a network call, it will need to be an asynchronous function and return the data via a callback. JSON Data: https://gist.githubusercontent.com/kvirani/f7d65576cc1331da1c98d5cad4f82a69/raw/4baad7566f0b6cd6f651c5d3558a015e226428b5/data.json The callback should be called with two arguments: error: if request comes back with an err, pass

Translating Curl Request with Form Data to Axios

I’m trying to mimic the following request using axios: More information: https://developer.capitalone.com/documentation/o-auth I came up with the following code: This keeps timing out and not giving me any response, which leads me to believe my request is malformed. Am I doing something wrong in trying to create this request with form data using axios? Answer See the documentation: params are

React-Query useQuery is caching response

I have following code This function should be called when I visit my main page, but when returning to this route from another page this request is not triggered and I don’t get fresh data. What I want is this query to be called every time like useEffect Answer data from the cache is always returned if there is data

Sending POST request with Fetch after closing the browser with ‘beforeunload’ / ‘unload’ eventlistener is not working

for the life of me I can’t figure out what is happening. I’ve been spending all day searching for the answer but can’t find it anywhere. I’m practicing with writing a function that emails an abandoned form to me. This is the index.js file I run for the local host that hosts the form The function that the request is

TypeError: fs.createReadStream is not a function

I prefer to use promises rather than callbacks so I’ve used util.promisify. I’ve received TypeError: fs.createReadStream is not a function at const attachments = {attachment: fs.createReadStream(‘kitty.png’)}; lane. How can I solve that? AdvertisementAnswer fs.promises is not a superset of fs. While it replaces some methods on fs with methods of the same core name that […]

MailChimp: Why is PUT method with javascript returning “Use PUT to insert or update list members”

I’m trying to update one of my subscriber’s status using mailchimp API 3.0, Meteor and javascript. Here is my js code I’m using: with and But I always have the same output: I20181204-18:42:12.714(8)? title: ‘Member Exists’, I20181204-18:42:12.714(8)? status: 400, I20181204-18:42:12.714(8)? detail: ‘(user mail adress) is already a list member. Use PUT to insert or update list members.’ But I am

How to decode nock recorded response

How to ad-hoc decode/uncompress the output produced by the nock recorder so we can see the response as text? I guess we do not understand if the response is gzipped and/or encoded The object works find when we load it into nock, and our tests are behaving as we expect. To see what the API produced, we are having to

Advertisement